Skip to content

Commit 5a7506d

Browse files
Critical fix, resolves race condition that can appear in 3rd party usage
1 parent 10b8365 commit 5a7506d

File tree

1 file changed

+10
-0
lines changed
  • packages/block-library/src/dialog-element

1 file changed

+10
-0
lines changed

packages/block-library/src/dialog-element/view.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ const { actions: privateActions, state: privateState } = store(
176176
if ( dialog.isOpen ) {
177177
return;
178178
}
179+
// If already closing, don't start another close animation
180+
if ( dialog.isClosing ) {
181+
return;
182+
}
183+
// Only proceed if the dialog element is actually open in the DOM
184+
// This prevents the watcher from triggering close animations when the dialog
185+
// was never opened in the first place (e.g., on page load when isOpen initializes to false)
186+
if ( ! dialogElement.open ) {
187+
return;
188+
}
179189
// Start isClosing animation...
180190
privateState.dialogs[ id ].isClosing = true;
181191
// Allow for animation to complete...

0 commit comments

Comments
 (0)