by runarberg · 4y ago · 0 comments
And this rule of thumb is also incorrect (albeit by technicality). A form submit button goes somewhere (to the action response) and is a button.
I agree with the sentiment though, in general:
- If you are navigating through the page, use a link,
- if you are performing an action, use a button, (and in addition)
- if you are reveling some information, use a <details> <summary>
The OP widget is non of these, I would say it is an open question whether <details> <summary> is the right choice here.
Another semantically-reasonable possibility which allows separation of source and destination would be using a button with appropriate aria-controls and aria-expanded to link it to the picker body; and probably giving that body the dialog role.
But I think the dismiss button, inside the dialog warrants it being a <dialog>. Dialogs usually open with a <button> (so that answers that question), and you would open this by calling dialog.show()—as opposed to the usual dialog.showModal()—since you don’t want to capture the focus. The Benefit of using the <dialog> element is that you can put it anywhere you want inside your DOM structure and allow it to interact with the page however you want to.