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

Add ToggleEvents to <dialog>.showModal() #9733

Open
keithamus opened this issue Sep 14, 2023 · 4 comments · May be fixed by #10091
Open

Add ToggleEvents to <dialog>.showModal() #9733

keithamus opened this issue Sep 14, 2023 · 4 comments · May be fixed by #10091
Labels
addition/proposal New features or enhancements topic: dialog The <dialog> element. topic: events

Comments

@keithamus
Copy link
Contributor

It is useful for web authors do determine when their <dialog> elements open and close. popover already has ToggleEvent which is dispatched when a popover opens or closes, but <dialog> does not. The current way to detect when a <dialog> opens is to register a mutation observer to check for open, however, this is quite a lot of work where an event would be easier.

I propose we add dispatching of ToggleEvent for <dialog> also. To be explicit: when showModal is called, <dialog> should dispatch a ToggleEvent with newState=open. When a dialog is closed (via form or button or close signal) it should dispatch a ToggleEvent with newState=closed.

@keithamus keithamus added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: dialog The <dialog> element. agenda+ To be discussed at a triage meeting labels Sep 14, 2023
@lukewarlow
Copy link
Member

How about via show()? I assume it would also fire the toggle event?

@past past removed the agenda+ To be discussed at a triage meeting label Sep 15, 2023
@keithamus
Copy link
Contributor Author

keithamus commented Sep 15, 2023

During the WHATWG Triage Session at TPAC today, WHATWG has resolved that <dialog> will dispatch a cancelable beforetoggle event during open and non-cancelable during close, and non-cancelable toggle event an async tick after; similarly to how popover (and soon to be <details> - see #9743) will.

@keithamus keithamus removed the needs implementer interest Moving the issue forward requires implementers to express interest label Sep 15, 2023
@domenic
Copy link
Member

domenic commented Sep 15, 2023

Small correction: beforetoggle should be non-cancelable during close as well. (This matches popover.)

@keithamus keithamus linked a pull request Jan 25, 2024 that will close this issue
5 tasks
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 25, 2024
This patch implements beforetoggle and toggle events for dialog
elements. See spec issue: whatwg/html#9733

Bug: 1521813
Change-Id: I56e38230663990c8f1ed8ecd9307a6a881372605
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 25, 2024
This patch implements beforetoggle and toggle events for dialog
elements. See spec issue: whatwg/html#9733

Bug: 1521813
Change-Id: I56e38230663990c8f1ed8ecd9307a6a881372605
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 27, 2024
This patch implements beforetoggle and toggle events for dialog
elements. See spec issue: whatwg/html#9733

Bug: 1521813
Change-Id: I56e38230663990c8f1ed8ecd9307a6a881372605
@josepharhar
Copy link
Contributor

keith made a PR to implement this here: #10091
I wrote a chromium implementation here: https://chromium-review.googlesource.com/c/chromium/src/+/5238172

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 29, 2024
This patch implements beforetoggle and toggle events for dialog
elements. See spec issue: whatwg/html#9733

Bug: 1521813
Change-Id: I56e38230663990c8f1ed8ecd9307a6a881372605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: dialog The <dialog> element. topic: events
Development

Successfully merging a pull request may close this issue.

6 participants
@past @keithamus @domenic @josepharhar @lukewarlow and others