Open lukewarlow opened 11 months ago
Happy to bikeshed etc but my proposal would be a new modal
attribute. It wouldn't change anything by default it just acts as an indicator when used alongside the open attribute.
My thoughts on what <dialog modal>
would do when called with JS.
show()
- Throw an exception (I'm not fully set on this so could probably be persuaded either way).
showModal()
- Work as expected.
<dialog popover modal>
would be an author error and would throw in some cases. Not sure which one should win though.
This could also simplify the invoker proposal. Currently we have a toggleModal action, and Keith has added an additional toggle
action inside of his Chromium CL.
If we added a new modal
attribute, we could just have a single toggle
action that would just work as expected?
Depending on the behaviour of show()
JS function, we could even just have a show
action and forget showModal
?
Adding to agenda as it might help simplify the invokers work that's ongoing. (Would obviously need WHATWG buy in too)
If we added a new modal attribute
Could <dialog open="modal">
not work?
Could
It would potentially for the open as modal on page load. Potentially as I'm not sure on changing boolean attribute to take values. I guess it was done with hidden so could be fine?
It wouldn't, however, additionally remove ambiguity around invoker actions though.
Potentially as I'm not sure on changing boolean attribute to take values. I guess it was done with hidden so could be fine?
Yes this is fine as it will become an enumerated attribute where the invalid/empty states map to <whatever the current behaviour is>. The problem is that the current behaviour will need a name.
Naming things is hard, could that be another reason to use a new attribute for the modality instead. Then we get potential invoker benefits and we don't have to think of naming
Some quick references for naming and behavior, since a declarative "open when loaded" feature was initially part of Popover but was removed.
The Open UI Community Group just discussed [dialog] Declarative indicator for dialog modality
.
There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.
The invokers proposal is a brilliant addition and really helps solve some of the developer ergonomic issues with dialogs (along with much more).
However, it misses one key case as I mentioned in https://github.com/whatwg/html/issues/3567, you can't have a modal dialog load open with just HTML, you need JS to call showModal() or a user to click an invoker button.
My use case is that I sometimes have modal dialogs that are linked to a client side router where the URL controls their visibility. I currently call .showModal() on component mount. But if I could instead just do this declaratively that would remove the requirement for client JS execution (think SSR scenarios)
<dialog open>
works for non-modals but there's no equivalent for modal dialogs.