-
Notifications
You must be signed in to change notification settings - Fork 50
feat: improve logic for modal/flyout lifecycle handling #3215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 RC Packages PublishedLatest commit: aedaa64 Published 2 packages@hashicorp/[email protected]
@hashicorp/[email protected]
|
3330f34
to
2dd9284
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few high-level comments:
All these explanations need to be updated to reflect the new code logic (willDestroyNode
doesn't exist anymore)



The same on the Modal showcase demos.
I suspect there is still something not 100% working at logical level, see video below where the listener for the close
event seems not to be removed (that's my understanding, but I may be wrong).
Screen.Recording.2025-09-25.at.12.08.45.mov
I suggest to review all the use cases using a reduced set of examples, and making sure (via debugger
that the order of execution is what you would expect, for different ways to close the flyout). I've sent you a code patch in DM if you want to use it.
27eb83c
to
436972d
Compare
@didoo I looked into it more and I believe the fix you suggested was enough to make sure all the event listeners are removed correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus the one open question on the differences between the modal and the flyout this looks all good to me!
9cc6fbc
to
b04dfb7
Compare
b04dfb7
to
66797d6
Compare
66797d6
to
bc4cfad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes all look good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌
📌 Summary
If merged, this PR would use
registerDestructor
to trigger the close callback when a Modal or Flyout is closed to ensure the proper cleanup happens when a Modal/Flyout is removed from the DOM.TODO:
🛠️ Detailed description
There are 2 commits in this branch, one to simplify the lifecycle logic and another to fix the click outside to dismiss bug.
Lifecycle logic
This is a follow up from the Modal incident that happened earlier this summer when the modal is simply destroyed and removed from the DOM (eg. on submit) the onDismiss is not run, just the willDestroyNode method, which leaves the overflow applied to the body, making the page unscrollable.
A version of this solution was previously suggested in #2962, but was not used because it was safer to just revert the change that caused the bug.
The fix now is to refactor the
did-insert
andwill-destroy
functions into a new modifierregisterDialog
. This way, it is guaranteed to run when the component is inserted in the DOM and the cleanup function will run when it is removed.Click outside to dismiss (TBD)
There is also a fix for the pre-existing bug in the Modal where if
@isDismissDisabled
is set to true, you cannot click outside to dismiss the Modal is allowed to be dismissed again (existing showcase with the bug).To fix this, I recreate the click outside to dismiss functionality from
ember-focus-trap
in the Modal component.In the showcase, this causes extra click event handlers to be added to the DOM because of the perpetually "open" inline modal examples for VRT. The click event handlers are added and removed correctly for the demos at the bottom of the page.
NOTE: If we decide the click outside to dismiss change is too much to include in this PR, I can totally remove the commit.
Preview showcase
🔗 External links
Jira ticket: HDS-5038
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.