by SPBS · 3y ago · 0 comments
https://github.com/whatwg/html/issues/3567
> dialog elements are a great addition and I'm glad they're getting implemented, but a key part of their functionality relies on JavaScript: to open a <dialog> you need to use JavaScript to set the open attribute.
> It'd be great if there was a way to make a <a> or a <button> elements capable of opening dialogs.
> Precident already exists for page interactivity baked into HTML - for example <a href="#.."> can already scroll the page, and <details> elements are capable of hiding elements behind interactivity, so I think it stands to reason <dialog> elements could be opened by other page elements.
There's a sliding scale here, with html at one end and each page ships a parser and libraries at the other - why have an img tag, just let the page developer implement a JS based interpreter?
For an example, click on '?' in the top right corner here: https://aavi.xyz/proj/colors/
Weirdly, you can close them with a form submission, but you can’t open them with one.
<button onclick="document.querySelector('#my-dialog').showModal();">open my dialog</button>