-
Notifications
You must be signed in to change notification settings - Fork 56
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
Dispatching Toggle Events for Dialog open/close #1005
Comments
(Not a TAG opinion) I'm curious -- after this, do you also plan to work on adding In any case, dispatching |
Yes I’d be happy to also work on |
We discussed this in a breakout today: The two types ("before" and "on") of event seem like very useful things to have. Why is this "toggle" and not separate "open" and "close" events? The platform is not entirely consistent here, but these elements likely need distinct actions for the two cases. We don't see why this should be a single event type. (We'd also like to see a path toward harmonization of events across the platform, but that's a larger project.) We also agree with Dan about |
Having the separate event would likely lead to setting up 2 event listeners instead of one for some fairly common tasks, but I can see why it might be nicer for others. The design was borrowed from popovers to keep symmetry, which perhaps themselves borrowed from the details toggle event (which doesn’t have the new/oldstate properties because it can be observed via the open attribute). |
I think it would help to see the common cases where you'd need 2 event listeners with mostly the same code. It does make sense to align the 3 kinds of elements, but maybe that should be done by adding |
My intuition and experience with using these suggests that opening and closing ... or you could ship both, but that seems like a premature commitment to waste. |
We could go back on beforetoggle/toggle and replace them with beforeopen/beforeclose/open/close, but this was decided quite a long time ago for popover in openui (and whatwg?), and would require a fairly large deprecation process since its shipped in all browsers now. I'm not sure exactly where that discussion took place but I could find it if needed. |
@josepharhar I'd love to see the popover discussion that settled on |
FWIW it would not be as simple as This was discussed in 2021 as part of OpenUI (https://www.w3.org/2021/05/13-openui-minutes.html#t01) where Robert pointed out the precedent for event naming around So in 2022 whatwg/html#8386 was raised which proposed the various I'm sure @josepharhar could find more threads exposing this level of discussion but this is what I could find. |
@keithamus Perfect, thanks! It looks like the idea of unifying the As a personal, non-TAG, opinion I think https://w3ctag.github.io/design-principles/#consistency indicates that |
Another consideration here is that while |
こんにちは TAG-さん!
I'm requesting a TAG review of Dispatching Toggle Events for Dialog open/close.
It is useful for web authors do determine when their
<dialog>
elements open and close.popover
already hasToggleEvent
which is dispatched when apopover
opens or closes, but<dialog>
does not. The current way to detect when a<dialog>
opens is to register a mutation observer to check foropen
, 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: whenshow
orshowModal
is called,<dialog>
should dispatch aToggleEvent
withnewState=open
. When a dialog is closed (via form or button or close signal) it should dispatch aToggleEvent
withnewState=closed
.ToggleEvent
s to<dialog>.showModal()
whatwg/html#9733Further details:
You should also know that...
I've enabled this in Firefox nightly targeting 133, it is currently flagged in Chromium, but I've raised an I2S (https://groups.google.com/a/chromium.org/g/blink-dev/c/PxluqSXWXD4/m/7q3qwklWAAAJ) and I'm aiming to ship in M132.
The text was updated successfully, but these errors were encountered: