Re: Questions about the :focus-visible heuristics

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.

~TJ

Received on Friday, 19 February 2021 01:31:19 UTC