Re: [csswg-drafts] [selectors] :focus-visible on a <select> element (#5822)

Reopening this as maybe we were not in agreement before.

This problem of `<select>` matching `:focus-visible` was reported in Chromium in https://crbug.com/1148007, and that was [closed as WONTFIX by @alice with the following comment](https://bugs.chromium.org/p/chromium/issues/detail?id=1148007#c7):
> `<select>` is an interesting case. I know that it is an element that does take focus on click in Safari, to make the platform conventions on macOS. (You can reproduce this on https://boom-bath.glitch.me/tabindex.html which has a comprehensive suite of elements to test with.) The reason for this is that you can type the first few letters of an option to quickly jump through a long list.  
> 
> I think for similar reasons, it does take focus on mobile web browsers on iOS, as iOS shows a native picker at the bottom of the screen. I'm not sure what Android does these days.
> 
> I do think this is working as intended - when clicking a select element, the focus style gives you a hint that you might want to use the keyboard to interact with it, even if you weren't previously using the keyboard.

I tend to agree with the bug report that either the spec should be clearer or this behavior should be changed.
Actually I have [a patch to change that and align Chromium with Firefox on this](https://chromium-review.googlesource.com/c/chromium/src/+/2644906).


About the weird issue that @emilio found, with `:focus-visible` matching when outline wasn't show. I believe this is due to a Chromium bug, that [the click on the `<select>` is not considered a mouse click](https://source.chromium.org/chromium/chromium/src/+/b2c2a7a8bc510a4a06a43456b69cf58b8908a7b2:third_party/blink/renderer/core/html/forms/select_type.cc;l=234), so it believes it's a keyboard focus and for that reason it matches `:focus-visible`. I had to fix that on my previous patch too.


-- 
GitHub Notification of comment by mrego
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5822#issuecomment-767500749 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 26 January 2021 12:08:11 UTC