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

[selectors] :focus-visible should match when focus is programmatically moved into a dialog #7214

Closed
craigkovatch opened this issue Apr 13, 2022 · 7 comments

Comments

@craigkovatch
Copy link

craigkovatch commented Apr 13, 2022

Whether <dialog> or [role="dialog"], focus should become visible when it is programmatically moved from outside to inside a dialog.

e.g. if a user clicks a button that opens a dialog, and now a button is focused-by-default within the dialog per Dialog, that button should show an indicator regardless of whether the dialog was launched by mouse or keyboard. (Probably not for touch.)

This seems like a significant usability hole in the current heuristic, which I don't see discussed directly in other issues here (though I may have missed something, apologies if so).

I don't much experience contributing to CSS spec discussion, so please forgive (and educate) me if I'm posting this in the wrong place, or need to further explain my concern, etc.

@tabatkins
Copy link
Member

I haven't played with dialog yet - in such a situation, does such a button normally show a focus ring?

@tabatkins tabatkins added the selectors-4 Current Work label Apr 14, 2022
@craigkovatch
Copy link
Author

craigkovatch commented Apr 14, 2022

For the case of "focus moved from outside a dialog, to a button within that dialog", yes, focus ring is normally shown. Native dialogs do this in macOS, and Chrome does it for its UI dialogs as well. I'm not sure what Windows does these days, but I assume the same.

Needing to indicate what ENTER (or SPACE) will do in a dialog that just appeared is, I think, quite a standard and necessary UX convention. Especially for modal dialogs.

It could be argued that this should be specific only to buttons and not any element. I don't have strong opinions on that.

@tabatkins
Copy link
Member

I'm actually just asking if, in the example you provided, browsers currently draw focus rings. :focus-visible is meant to match the browser-default focus ring heuristics (and/or browser-default focus ring heuristics are meant to be defined by :focus-visible).

I agree that if a button is activateable as soon as a dialog opens it probably needs a focus ring to visually indicate that.

@craigkovatch
Copy link
Author

Currently only Safari shows a focus ring in this scenario -- mercifully it does so for both <dialog> and <div role='dialog'> elements.

Testing heuristics of confirm() for guidance:

Chrome yes:
image

Safari yes:
image

Firefox no:
image

@fantasai
Copy link
Collaborator

fantasai commented Nov 7, 2022

@craigkovatch If I'm understanding correctly, I think you're either asking for another bullet point in the example heuristic in the spec, or asking for the last bullet point to be modified, correct?

https://www.w3.org/TR/selectors-4/#the-focus-visible-pseudo

Could you take a stab at wording it so I know I'm understanding correctly what needs fixing? :)

tabatkins added a commit that referenced this issue Jan 7, 2023
@tabatkins
Copy link
Member

All right, we've added what we think is a reasonable distillation of the condition to the list of conditions, since Safari already has this behavior.

@craigkovatch
Copy link
Author

LGTM! Apologies that I did not reply @fantasai , lost track during a vacation. Thanks @tabatkins

jakearchibald pushed a commit to jakearchibald/csswg-drafts that referenced this issue Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants