#233: CSS Selectors 4, :focus-visible.

Visit on Github.

Opened Feb 26, 2018

こんにちはTAG!

I'm requesting a TAG review of:

We'd prefer the TAG provide feedback as (please select one):

  • open issues in our Github repo for each point of feedback
  • open a single issue in our Github repo for the entire review
  • leave review feedback as a comment in this issue and @-notify [github usernames]

Discussions

Comment by @dbaron Mar 13, 2018 (See Github)

I think this is small and relatively non-controversial. It's existed in Gecko for a while as :-moz-focusring.

I guess the biggest thing I wonder about when reading the specification is whether the conformance criteria should be as loose as they are, or whether they should be a little bit more specific. I guess it's probably fine as they are.

So, basically, I think this is fine.

Comment by @bkardell Mar 14, 2018 (See Github)

I think that there are a few cases where we actually have verified through use of the polyfill and feedback from some fairly widely used sites/apps that we would kind of not want it to match exactly what :-moz-focusring does. In spirit, yes, it is the same animal... Agree that we don't want to get too over-specified about it but we were working on a pull that describes it better.. Maybe we should finish that? I think it might be worth looking at the tests, if the tests are up to date (honestly, @robdodson would know a lot better at this point)? So... idk, fwiw, I do think we may want it to be just a little more wordy, at least in the note about intent if not actually specified strict conformance criteria?

Comment by @robdodson Mar 14, 2018 (See Github)

Yep the tests are up to date :) As Brian mentioned, we are working on a PR to better describe the intent and we might delve a bit more into conformance. We can follow up on this thread when we've refined that language.

Discussed Mar 20, 2018 (See Github)

(David is frozen on Jitsi. We love WebRTC.)

David: I raised the question of whether the spec is detailed enough for conformance requirements, and the feedback was it might not be - whether we should leave our issue open or not is unclear.

Peter: We should mark as pending.

ACTION: Revisit during F2F.

Comment by @robdodson Mar 29, 2018 (See Github)

We've sent a PR to the spec to try to better spell out the intent of the selector and give a bit more conformance criteria.

https://github.com/w3c/csswg-drafts/pull/2481

Comment by @torgo Apr 5, 2018 (See Github)

session scheduled for Saturday on this

Comment by @dbaron Apr 7, 2018 (See Github)

We took a look at the PR, and will cycle back again in a few weeks.

Comment by @travisleithead Apr 17, 2018 (See Github)

Maybe this is my lack of understanding, but if I target an element with both :focus and :focus-visible in a stylesheet, won't the :focus rule make the :focus-visible rule never work? (Since :focus always applies when an element is in focus, and :focus-visible conditionally applies?) So, if I, as a developer, want to start using :focus-visible in my stylesheet for UA's that support it, but keep :focus around for those that don't, I guess I must resort to @supports? Or is it understood somehow that :focus-visible wins over :focus assuming specificity is otherwise equal?

Comment by @bkardell Apr 17, 2018 (See Github)

Nothing special about this, basically, so yes... whatever wins, wins. That seems pretty standard css fare though. A better temporary option is probably to use the speculative polyfill and avoid :focus altogether.

A big part of the issue here is that because :focus doesn't match UA styles there's really no 'good' way to use it on many sites. Using it negatively impacts user experience by either showing indicators when they shouldn't or (surprisingly often) just never showing them at all because people can't work out how to avoid the too often problem.

Comment by @dbaron Apr 17, 2018 (See Github)

I agree that if you want :focus rules only for UAs that don't support :focus-visible, they would need to be in an @supports rule, although currently you can't test selector support with @supports rules, so it's not actually doable. (We need to add that at some point; we might even have a WG resolution to do so...)

Comment by @travisleithead Apr 17, 2018 (See Github)

OK. Glad to get that confirmed. Thanks!

Comment by @robdodson Apr 17, 2018 (See Github)

Adding pseudo classes to @supports would be a huge help.

As Brian mentioned, without @supports, using the polyfill may be the easiest way to provide backwards compatibility.

Another possible trick suggested by the Paciello Group would be to do something like:

button:focus { /* some exciting button focus styles */ }
button:focus:not(:focus-visible) {
    /* undo all the above focused button styles
       if the button has focus but the browser wouldn't normally
       show default focus styles */
}
button:focus-visible { /* some even *more* exciting button focus styles */ }

I haven't tested it across all browsers, but the author suggests that if the browser doesn't know about the pseudo class in the :not() bit, then it ignores the entire selector.

Discussed Apr 24, 2018 (See Github)

Travis: I looked at this last week. Added some commentary. Otherwise, this review is done. My comments have been responded to.

David: I agree, as long as that PR they had is merged. We reviewed the PR... but it's not merged yet.

Alex: Travis wanted to close the issue?

Dan: Yes, but if the PR isn't merged...

David: I'll check with the editors.

Comment by @torgo Apr 24, 2018 (See Github)

Still waiting on status / fate of w3c/csswg-drafts#2481 ... we will keep this open for now and come back to it.

Comment by @robdodson Apr 25, 2018 (See Github)

I chatted with @tabatkins today, he said he wanted to take a stab at updating the spec text based on our discussion and some of the content in the linked PR.

Discussed May 22, 2018 (See Github)

@torgo: Moving to the 29th

Comment by @dbaron Jul 17, 2018 (See Github)

Seems that the CSS WG discussion has now moved to w3c/csswg-drafts#2897, which is still open.

Discussed Aug 21, 2018 (See Github)

DB: I've pinged folks yesterday to discover status of the PR. No response. Maybe push this out again?

PL: Two more weeks?.

Comment by @dbaron Sep 4, 2018 (See Github)

That PR is now merged, so the text is now part of the spec.

Comment by @travisleithead Sep 11, 2018 (See Github)

Looks great to me!

Comment by @travisleithead Sep 11, 2018 (See Github)

The TAG reviewed the merged PR and is satisfied with the result. Thanks everyone for your participation, and we hope you consider us for your future reviews!