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

Should popover and dialog share the same "previously focused element"? #9063

Closed
cathiechen opened this issue Mar 22, 2023 · 4 comments
Closed
Labels
normative change topic: dialog The <dialog> element topic: popover The popover attribute and friends

Comments

@cathiechen
Copy link

According to [1], IIUC, each element has one "previously focused element", popover and dialog both work on it.
If dialog is with popover, then we might lose the focus before dialog.show().

<dialog popover>This is a modal dialog</dialog>
<script>
  dialog.show();
  popover.showPopover();
  popover. hidePopover();
  dialog.close();
</script>

Should we indicate that they do not share "previously focused element"? @josepharhar @nt1m @emilio

[1] https://html.spec.whatwg.org/multipage/interactive-elements.html#previously-focused-element

@annevk annevk added normative change topic: dialog The <dialog> element topic: popover The popover attribute and friends labels Mar 23, 2023
@josepharhar
Copy link
Contributor

I'm not sure if <dialog popover> was an intended use case when we decided to combine the previously focused elements.
I'm not opposed to splitting them up again if anyone feels strongly about it. Chromium's implementation actually still uses separate previously focused elements.

@domenic
Copy link
Member

domenic commented Mar 23, 2023

If we fix #8904 I think this might also get solved? And that issue seems kind of high priority to me.

@cathiechen
Copy link
Author

If we fix #8904 I think this might also get solved? And that issue seems kind of high priority to me.

Not quite the same, if there is autofocus inside dialog.

<dialog popover> <button autofocus>This is a modal dialog</button></dialog>
<script>
  // focus on node outside dialog 
  popover.showPopover(); // set the node to previously focused element
  dialog.show(); // set button to previously focused element
  dialog.close(); // clear previously focused element
  popover. hidePopover();
</script>

And yes, I agree this is a corner case, not a high priority:)

@josepharhar
Copy link
Contributor

Dialog elements can be open as popovers, but they can't be open via show()/showModal() and showPopover() at the same time. The example code provided, whether show() or showPopover() is called first, will throw an exception instead of following through.

I don't think that this can be an issue, so I'm going to close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative change topic: dialog The <dialog> element topic: popover The popover attribute and friends
Development

No branches or pull requests

4 participants