Skip to content

improved functionality making modals draggable and cleanup after closing - #1071

Merged
M-Wicenec merged 3 commits into
masterfrom
eagle-1640
Sep 30, 2026
Merged

M-Wicenec merged 3 commits into
masterfrom
eagle-1640

Conversation

@M-Wicenec

@M-Wicenec M-Wicenec commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

the code making modals draggable after opening is now targeting that specific modal instead of applying the drag ability status to all.
after closing the modal, the drag listener is cleaned up

Summary by Sourcery

Scope modal dragging and teardown to individual modal instances and restore their state after closing.

Bug Fixes:

  • Ensure modal dragging and cleanup are scoped to the modal being opened or closed, preventing other modals from being affected.

Enhancements:

  • Clean up draggable instances and modal drag listeners when modals close, while resetting their position, styles, and interaction state.

Chores:

  • Remove duplicate modal cleanup handling from the application entry point.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates modal dragging to operate on the specific modal instance and cleans up its draggable widget and namespaced event listener on close, while scoping position, style, and pointer-event resets to that modal.

Sequence diagram for modal drag setup and cleanup

sequenceDiagram
    participant User
    participant Modal
    participant Dialog as ModalDialog
    participant Header as ModalHeader

    User->>Modal: show.bs.modal
    Modal->>Dialog: draggable({handle: '.modal-header'})
    User->>Header: mousedown
    Header->>Modal: css(pointerEvents: none)
    Header->>Modal: css(modal-content pointerEvents: all)
    User->>Modal: hidden.bs.modal
    Modal->>Dialog: draggable('destroy')
    Modal->>Header: off('mousedown.modalDrag')
    Modal->>Dialog: css(left: 0px, top: 0px)
    Modal->>Modal: css(pointerEvents: auto)
    Modal->>Modal: find('.modal-content').css(pointerEvents: auto)
Loading

File-Level Changes

Change Details Files
Scope draggable behavior and cleanup to the modal instance being opened or closed.
  • Initialize dragging only on the current modal’s dialog.
  • Namespace the header mousedown handler for targeted removal.
  • Destroy the draggable instance and remove the namespaced listener when the modal closes.
src/Eagle.ts
Restrict modal reset operations to the closing modal instead of affecting all modals.
  • Reset dialog position, modal-specific styles, and pointer-events through the current modal reference.
  • Preserve selection reset while avoiding global modal state changes.
src/Eagle.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/Eagle.ts" line_range="5752" />
<code_context>
+        modal.find('.modal-header').off('mousedown.modalDrag');
+
+        //reset modal dialog position and styles
+        dialog.css({"left":"0px", "top":"0px"})
+        modal.find("#editFieldModal textarea").attr('style','')
+        modal.find("#issuesDisplayAccordion").parent().parent().attr('style','')
</code_context>
<issue_to_address>
**issue (broader_impact):** The existing `$('.modal').on('hidden.bs.modal', ...)` handler in `src/main.ts` still resets `$('.modal-dialog')` globally whenever any modal closes, so closing one modal resets the position of every modal dialog instead of only the modal being closed.

**Triggers:** When more than one modal is present or another modal remains open while a modal is hidden.

**Suggested fix:** Remove the duplicate global hidden-modal reset in `src/main.ts` or scope that handler to its `this` modal as well.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/Eagle.ts:5752


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/Eagle.ts

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@james-strauss-uwa james-strauss-uwa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had one question about this. If you need both listeners, and they are different for a good reason, then go ahead and merge.

Comment thread src/main.ts Outdated
@@ -198,7 +198,7 @@ $(function(){
}

$('.modal').on('hidden.bs.modal', function () {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are both this event listener and the event listener in Eagle.ts:5743 required? They both seem to listen for 'hidden.bs.modal'.

And they are slightly different. Maybe add the "const modal" and "const dialog" lines here so they look more similar? The function above does about 8 things, and the function here does 3 of the same things but not the other 5?

It just looks a bit strange.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! ive removed the main.ts listener function. in fact the eagle one already does everything the one in main.ts did anyways

@M-Wicenec
M-Wicenec merged commit 7acd754 into master Sep 30, 2026
4 of 5 checks passed
@M-Wicenec
M-Wicenec deleted the eagle-1640 branch September 30, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants