Skip to content

Conversation

shleewhite
Copy link
Contributor

@shleewhite shleewhite commented Sep 19, 2025

📌 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:

  • test in cloud ui (it was tested in cloud ui back in june, but will test again)

🛠️ 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 and will-destroy functions into a new modifier registerDialog. 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
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

Copy link

vercel bot commented Sep 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
hds-showcase Ready Ready Preview Oct 1, 2025 1:24pm
hds-website Ready Ready Preview Oct 1, 2025 1:24pm

@shleewhite shleewhite marked this pull request as ready for review September 22, 2025 20:39
@shleewhite shleewhite requested a review from a team as a code owner September 22, 2025 20:39
@shleewhite shleewhite added the release-candidate Publishes release candidates to npm label Sep 23, 2025
Copy link
Contributor

github-actions bot commented Sep 23, 2025

📦 RC Packages Published

Latest commit: aedaa64

Published 2 packages

@hashicorp/[email protected]

yarn up -C @hashicorp/design-system-components@rc

@hashicorp/[email protected]

yarn up -C @hashicorp/design-system-tokens@rc

Copy link
Contributor

@didoo didoo left a 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)

Image Image Image

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.

@shleewhite
Copy link
Contributor Author

@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.

Copy link
Contributor

@dchyun dchyun left a 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!

Copy link
Contributor

@dchyun dchyun left a 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!

didoo
didoo previously approved these changes Sep 30, 2025
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

LGTM 👌

@shleewhite shleewhite requested a review from didoo October 1, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants