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 hide popover algorithm always restore the previously focused element? #9169

Closed
nt1m opened this issue Apr 14, 2023 · 5 comments · Fixed by #9018
Closed

Should hide popover algorithm always restore the previously focused element? #9169

nt1m opened this issue Apr 14, 2023 · 5 comments · Fixed by #9018
Labels
topic: popover The popover attribute and friends

Comments

@nt1m
Copy link
Member

nt1m commented Apr 14, 2023

According to https://html.spec.whatwg.org/#hide-popover-algorithm , the answer is yes.

According to WPT/Chrome's implementation, the answer is no. The previously focused element should be restored only when focus is currently in the popover. (This behavior does seem to make sense to me fwiw)

@nt1m nt1m added the topic: popover The popover attribute and friends label Apr 14, 2023
@nt1m
Copy link
Member Author

nt1m commented Apr 14, 2023

cc @rwlbuis @josepharhar @mfreed7

@nt1m
Copy link
Member Author

nt1m commented Apr 14, 2023

Fwiw, the original Chromium commit is at: https://chromium-review.googlesource.com/c/chromium/src/+/4322607

Not sure if contains() takes in account shadow DOM trees (it might, I'm not sure).

@Yay295
Copy link
Contributor

Yay295 commented Apr 14, 2023

The previously focused element should be restored only when focus is currently in the popover.

I suppose this is to allow you to set the focus to something while the popover is open? I think there was another issue in this repository about doing that, but I don't remember if it came to a conclusion.

@mfreed7
Copy link
Collaborator

mfreed7 commented Apr 14, 2023

According to https://html.spec.whatwg.org/#hide-popover-algorithm , the answer is yes.

According to WPT/Chrome's implementation, the answer is no. The previously focused element should be restored only when focus is currently in the popover. (This behavior does seem to make sense to me fwiw)

We discussed this to get to the current behavior in Chromium, which I do think is better. The problem case without this special casing is that the user opens a popover, then tab-navigates somewhere else and activates another button. That light dismisses the popover, but feels very odd for the focus to suddenly shift back to the popover activating button. It feels natural if the focus is still within the popover, since it has to go somewhere from there now that the popover is closing.

Sorry - I thought we had also put up a spec PR to discuss this change. @josepharhar do you know if there's a PR somewhere for this?

@nt1m
Copy link
Member Author

nt1m commented Apr 14, 2023

Ah looks like there was a PR put up a month ago about this: #9018 and I forgot. Sorry

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

Successfully merging a pull request may close this issue.

3 participants