opened-changed event detail exposes opened state #2334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I Did
Event
withCustomEvent
to include theopened
state in the event's detail.CustomEvent
now also references the host element in its event target.Note:
The
opened-changed
event previously lacked detail, and theevent.target
wasnull
, making it impossible to determine the dialog's state within the event. This caused issues when attempting to control the dialog's state dynamically via theopened
property.A potential scenario is where a user dynamically triggers the dialog through the
opened
property, expecting to open or close the dialog accordingly. However, when the ESC key is pressed and the dialog closes, the state is not synced externally. As a result, the dialog might not reopen the next time theopened
property is set totrue
.By including
{ detail: { opened: true/false } }
, it becomes possible to accurately determine the dialog's state and update theopened
property externally, ensuring it remains in sync with the actual dialog state.