2 ms·
So for the https://tools.simonwillison.net/side-panel-dialog https://tools.simonwillison.net/side-panel-dialog example - where clicking on an item opens up a "d
by simonw 2y ago
So for the https://tools.simonwillison.net/side-panel-dialog https://tools.simonwillison.net/side-panel-dialog example - where clicking on an item opens up a "details" view in a side panel, which can then be dismissed - is the way I'm using dialog appropriate? If not, how should I use it instead?
Code is here: https://github.com/simonw/tools/blob/main/side-panel-dialog.html https://github.com/simonw/tools/blob/main/side-panel-dialog....
Key code is that when you click an item it effectively does this:
sidePanel.innerHTML = '...';
sidePanel.showModal();
I think this is a modal, because it's meant to entirely take focus from the rest of the page (until you dismiss the side panel).
- no_wizard 2y agoIt looks to me like you’re using the dialog API well enough, but your background content isn’t inert, I can still scroll it, and if I wasn’t on mobile I’d see if tab would break the modal sandbox, as I suspect it might. You should try using this with a screen reader if you’re able, that’ll let you know where you may need further improvement. Right now the behavior on the page is that of a dialog and you’re using the (correct if you want a modal) modal API, that will cause issues for users You should also use the autofocus attribute if you want the modal to focus on something other than the close icon in the corner upon opening
- simonw 2y agoI just added a toggle to https://tools.simonwillison.net/side-panel-dialog https://tools.simonwillison.net/side-panel-dialog that switches between show() and showModal() to help me explore the differences.