W3C home > Mailing lists > Public > www-archive@w3.org > February 2021

Re: Questions about the :focus-visible heuristics

From: Alice Boxhall <aboxhall@google.com>
Date: Fri, 19 Feb 2021 12:32:52 +1100
Message-ID: <CAMQHGLzZ3RkGDZV7PDtKSeYMTa_N1zt++4NN2DR_0Q=HRgvkYg@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Emilio Cobos Álvarez <emilio@crisal.io>, fantasai <fantasai@inkedblade.net>, www-archive@w3.org
On Fri, Feb 19, 2021 at 12:31 PM Tab Atkins Jr. <jackalmage@gmail.com>
wrote:

> On Thu, Feb 18, 2021 at 4:09 PM Emilio Cobos Álvarez <emilio@crisal.io>
> wrote:
> > On 2/19/21 00:30, Tab Atkins Jr. wrote:
> > > Well, Chrome draws a focus ring on that element on click too, so it's
> > > still consistent. I guess Firefox does treat them differently, but at
> > > least with regards to the "pay attention to what was previously
> > > focused" text, both seem to ignore what was previously focused.
> >
> > Chrome Dev does not. Chrome stable doesn't match :focus-visible on
> > click, either, it shows an outline because of a bug that has been fixed
> > by rego already (Chrome was using :focus in the UA sheet rather than
> > :focus-visible).
>
> Argh, computers are the worst. Okay.
>
> > Also, I don't think we both ignore what was previously focused, see this
> > test-case for example, which in Firefox correctly makes the <div> match
> > :focus-visible because the previously focused element did:
> >
> > <!doctype html>
> > <input placeholder="When you focus me..."
> > onfocus="this.nextElementSibling.focus()">
> > <div tabindex="0">
> >    ... I should take focus and draw an outline
> > </div>
> >
> > And this one, where it doesn't show a ring for the same reason:
> >
> > <!doctype html>
> > <div tabindex="0" onfocus="this.nextElementSibling.focus()">
> >    When you focus me with mouse...
> > </div>
> > <div tabindex="0">
> >    ... I should take focus and _not_ draw an outline
> > </div>
> >
> > If you have a test-case where that doesn't happen, I'd be interested in
> > taking a look, I wrote that line of code[1] :)
>
> My test had the focus get transferred from a div to an input, which
> drew the focus outline. If these "focus-transfer" heuristics are meant
> to be less powerful than the preceding heuristics, then this makes
> sense, but I didn't get that sense from the text. I can rewrite them
> to more carefully imply that.
>

An <input> will always match :focus-visible when focused, because it takes
text input.

It might be worth going through the WPT tests
<https://wpt.fyi/results/css/selectors?label=master&label=experimental&aligned&q=focus-visible>
to get a feel for what behaviour is and isn't expected.


>
> ~TJ
>
Received on Friday, 19 February 2021 01:33:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 19 February 2021 01:33:43 UTC