Re: [w3ctag/design-reviews] Invokers API (Issue #920)

To add to Luke's commentary:

> Is there a way to detect that this feature exists?

`'invokeTargetElement' in HTMLButtonElement.prototype` or `'invokeAction' in HTMLButtonElement.prototype`, either one will do.

> Why is there no generic .invoke() method for invocation targets? If targets have default action (called "auto"?) this might make it more ergonomic for authors rather than needing to work out how to achieve an action.

Generally speaking invoke actions map to imperative APIs, where "auto" is an alias for "do the most common action". So if an invoker is pointing to a popover, the default action is to call `togglePopover()`, if it is pointing to a dialog, it will call either `close()` or `showModal()` depending on the state of the dialog. We spoke of adding a `toggleModal()` to Dialog, and have https://github.com/openui/open-ui/issues/954 raised to decide if we should more closely map the actions to imperative APIs, which may mean adding new methods.

> Why does <details> have "toggle" and "auto" actions doing the same thing?

"auto" is the stand-in for when the attribute value is missing, so `<button invoketarget=my_details>` (no `invokeaction`) will do the `"auto"` behaviour. This is being changed to be "the auto state" (as in a null or empty string of the attribute) so explicitly `"auto"` will do nothing. See https://github.com/openui/open-ui/pull/1006

> Does invoking alter focus? [...] Whatever the behavior is, it should be specified so to be consistent across UAs.

"It depends". When it does, it will most certainly be specified. Specifically for a `popover` it runs the popover focusing steps - which may or may not change focus, and for `<dialog>` elements it runs the dialog focusing steps, which definitely does change focus. Those are the only two specced right now but the others we will be sure to specify whether they change focus or not.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/920#issuecomment-1965501674
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/920/1965501674@github.com>

Received on Monday, 26 February 2024 23:18:17 UTC