[Webkit-unassigned] [Bug 234077] [selectors] :focus-visible not matching on accessKey focus after focusing something via mouse

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Dec 13 04:23:18 PST 2021


https://bugs.webkit.org/show_bug.cgi?id=234077

--- Comment #1 from Manuel Rego Casasnovas <rego at igalia.com> ---
The problem here is related to this code in Element::focus():
        FocusOptions optionsWithVisibility = options;
        if (!document->wasLastFocusByClick())
            optionsWithVisibility.visibility = FocusVisibility::Visible;

That code is needed to make focus-visible-script-focus-* tests to pass.
Basically when you have clicked on a focusable element (maybe a <div tabindex> or a <button> on Linux) if the event handler of that click, focuses something else (e.g. something in a dialog that it opens), you shouldn't not get a focus-ring in the newly focused element.

The problem is that this Element::focus() is used from JavaScript focus(), but is also used in many other places internally.
For all those internal usages, we're getting this behavior that might be not correct (depending on if the previous focused element was focused by click or not).
One of those places is accessKeyAction() methods, for them we always want to show focus-visible, so we don't care about if the last focused element was by click or not.

I'm not sure what's the best way we can differentiate if Element::focus() has been called from JavaScript, or it has been called internally.
One idea could be to have a Element::internalFocus() that we only use internally, and keep Element::focus() only for script focus.
Another could be adding a new FocusTrigger::Internal, and pass it properly in all the internal callers to Element::focus().
Not really sure what's the best approach, or if there are better alternatives.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211213/d283c0c6/attachment-0001.htm>


More information about the webkit-unassigned mailing list