openui / open-ui

Maintain an open standard for UI and promote its adherence and adoption.
https://open-ui.org
Other
3.59k stars 191 forks source link

[invokers] add a way to list supported commands? #1068

Open bkardell opened 4 months ago

bkardell commented 4 months ago

In the w3c TAG review, there was a closing comment that

We think that this would be more useful if it were possible to get the list of available actions from elements.

1020 is related - I don't know if we've ever really fully discussed this feedback.

lukewarlow commented 1 month ago

Thinking on this there's a number of places where there's a getSupportedX() function. So a getSupportedCommands() function could work okay? I don't see a problem with adding it?

@keithamus what would you think about it?

You would have potentially interesting situations such as <div popover> returning ['toggle-popover', 'show-popover'...] but <div> returning nothing?

How contextual should it be? Would a closed dialog support the 'close' action?

I think we probably already have a HTML spec concept for retrieiving if an action is valid in a given context, so perhaps we can somewhat piggy back off that?

keithamus commented 1 month ago

It seems reasonable I'm just not overly convinced on the use case. It seems to mostly be feature detection for polyfills but I think it's reasonably tenable to implement polyfills without the need for such explicit feature detection APIs.

rebeccadavidsson commented 1 month ago

If listing available actions is not an option for now, it would be nice to provide a warning in the HTML or the browser when an action is invalid given the context (or just because of a typo)