You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "close" command will almost always be used to close the dialog that the close button is in.
Similarly a button set to "hide-popover" will, a great deal of the time, be nested inside the popover that it hides.
Needing to reference a unique id makes reuse awkward. If I reuse the same UI element on the same page by copy/pasteing some HTML, needing to look through the markup and update every id and commandfor is laborious and error-prone.
It would be useful to be able to refer to the nearest ancestor popover/dialog element, rather than only being able to reference an id, which needs to be unique every time.
Something like commandfor="parent", commandfor="closest", commandfor="this" or commandfor="self"
If the command is set to "close", it would find the nearest ancestor dialog. If command is set to "hide-popover" it would reference the nearest ancestor popover.
I think this would have been nice default behaviour if the commandfor attribute was omitted, but if that's not possible this would at least be better than nothing.
For certain UI components, like a large nested menu, for example, many buttons, each with a command and commandfor might be used, which makes referencing ids particularly onerous.
I like the idea of a defaulting to dialog button is in as the commandfor value, can see it save a lot of awkward manual setting up, like in the cases you describe.
Fwiw I'm completely supportive of this idea, I also liked the idea of implicit commands. Both were in various states of being in the proposals originally. They've been dropped from v1 based on discussions in whatwg. But we can potentially bring either of them back in future (modulo compat concerns).
Things to consider is what would .commandForElement reflect? How would this work with the referencetarget proposal?
I actually think this is potentially more doable than implicit commands especially given that the commands will generally be unique to a specific element so will make searching for a valid target easier.
The
"close"
command will almost always be used to close the dialog that the close button is in.Similarly a button set to
"hide-popover"
will, a great deal of the time, be nested inside the popover that it hides.Needing to reference a unique id makes reuse awkward. If I reuse the same UI element on the same page by copy/pasteing some HTML, needing to look through the markup and update every
id
andcommandfor
is laborious and error-prone.It would be useful to be able to refer to the nearest ancestor popover/dialog element, rather than only being able to reference an
id
, which needs to be unique every time.Something like
commandfor="parent"
,commandfor="closest"
,commandfor="this"
orcommandfor="self"
e.g.
If the command is set to "close", it would find the nearest ancestor dialog. If command is set to "hide-popover" it would reference the nearest ancestor popover.
I think this would have been nice default behaviour if the
commandfor
attribute was omitted, but if that's not possible this would at least be better than nothing.For certain UI components, like a large nested menu, for example, many buttons, each with a
command
andcommandfor
might be used, which makes referencing ids particularly onerous.https://codepen.io/cssgrid/pen/raBbMPL
The text was updated successfully, but these errors were encountered: