Skip to content
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

<button type="action"> for performing a specified action on a specified element #10010

Closed
oscarrdy opened this issue Dec 19, 2023 · 2 comments
Closed
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@oscarrdy
Copy link

oscarrdy commented Dec 19, 2023

What problem are you trying to solve?

Methods on HTML elements like the dialog element's show() and showModal() methods cannot currently be invoked without using JavaScript. Additionally, assistive technology have no way of understanding what action a button with type "button" and underlying JavaScript will perform.

What solutions exist today?

Using inline JavaScript with the onclick attribute like: onclick="myElement.myMethod()" close to achieves the same. However if inline JavaScript is disabled, it would not work. Additionally, assistive technology would not be able to understand what method is about to be called and on what element.

How would you solve it?

This can be solved by creating a new button type called "action". This type would also take an "action" attribute and a "for" attribute to specify what the action is and what element it is for. This would for example look like this:

<dialog id="myDialog">
    Hello World
</dialog>

<button type="action" action="showModal" for="myDialog">
    Open Dialog
</button>

Other use cases could be:

  • Calling the submit or reset methods on forms.
  • Calling the play method or other video/audio related methods on video and audio elements.
  • Calling the focus method on focusable elements.
  • Calling the requestFullscreen method on elements.
  • If elements like details or other current or future openable/closeable elements gained show() and close() methods like the dialog.

Anything else?

No response

@oscarrdy oscarrdy added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Dec 19, 2023
@YummyBacon5
Copy link

This is almost exactly the same as invoker buttons by the Open UI CG

Where your action attribute is invokeaction
And the for attribute works the same as invoketarget

@oscarrdy
Copy link
Author

@YummyBacon5 You are right, thanks for pointing that out.

@oscarrdy oscarrdy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
@oscarrdy oscarrdy changed the title New feature: <button type="action"> for performing a specified action on a specified element <button type="action"> for performing a specified action on a specified element Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants