Skip to content
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

fix(dialog): fixed escape key bug when persistent and improved destroy logic #823

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

DRiFTy17
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added/updated: N
  • Docs have been added/updated: N
  • Does this PR introduce a breaking change? N
  • I have linked any related GitHub issues to be closed when this PR is merged? N

Describe the new behavior?

This PR contains a fix for a bug in Chrome where where pressing the escape key twice in succession would always close the native <dialog> because you can't prevent default on the cancel event multiple times... This is seen as a bug by the community but Chrome has said that it is not. The workaround is to just use a keydown listener on the window and prevent default when the escape key is pressed, and this works across all browsers but is unfortunate.

The second fix included with this PR is the teardown logic for when a dialog is removed from the DOM before the close animation is complete (by setting open to false). This was causing some cleanup logic to not run. We now will always run the proper cleanup logic from the disconnectedCallback() regardless of the animation state, and this ensures that any resources are released and state is reset properly.

@DRiFTy17 DRiFTy17 added the patch Increment the patch version when merged label Feb 12, 2025
@DRiFTy17 DRiFTy17 requested a review from a team as a code owner February 12, 2025 20:49
Copy link

stackblitz bot commented Feb 12, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@DRiFTy17 DRiFTy17 added the skip-release Preserve the current version when merged label Feb 14, 2025
@DRiFTy17 DRiFTy17 merged commit e4bd264 into main Feb 14, 2025
13 checks passed
@DRiFTy17 DRiFTy17 deleted the fix-dialog-escape-and-cleanup branch February 14, 2025 14:55
Copy link
Contributor

🚀 PR was released in v3.6.2 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released. skip-release Preserve the current version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants