-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:focus-visible's "hidden focus" artifact can result in user UI confusion on Mac #257
Comments
I think Chrome has had the behavior where it would focus the button on click, but hide the focus ring since before we started working on :focus-visible. I'm not sure what the thinking was behind that original decision, but I have heard at least one person argue in favor of it because they think that a user may mouse click on a button and then want to click it again using their keyboard, which would be possible on Chrome but not on Safari (I don't think?) because Safari doesn't put focus on the button when you mouse click it. But if it's standard across all of macOS that buttons don't receive focus when they're mouse clicked, then maybe it's worth adopting that same approach in the browser. I can definitely understand the user argument that "buttons work this way on my computer except when I use this particular browser" and that being annoying for them.
Do you feel like the macOS/Safari behavior is correct here? For instance, if I click to drag a slider—but perhaps my mouse dexterity isn't perfect—in Chrome I can press the arrow keys to dial it up or down by a few units, and I'll see a focus ring as I do this. But in Safari I would need to use my keyboard to navigate back to the slider (from wherever focus is). If I tried to press the keyboard after dragging it, it would scroll the page. |
I acknowledge there are benefits to either approach, but rather than discuss the value judgement of which is more "correct," I'd like to focus on the general Mac platform conventions and user expectations that:
|
I think this is the critical one, and the real rub here stems primarily from the fact that div buttons already work inherently different from standard apple-philosophy buttons, but also have no way of working just like windows-philosophy buttons either. Combine this with the fact that there isn't a focus model that describes this hybrid thing either. That is, as @cookiecrook mentioned above, tabIndex values are more windows-like -- there is no way to say "this isn't a mac button, but I want to it work like that in terms of only being keyboard focusable". We've been disussing aspects of this for years, even here the discussions began way way before #42 (comment) I am (still) pro us making it possible to be clear about this because there is quite obviously no "right" default that works for all cases of what a focusable div might intend to be - it really depends. That said, here are my (personal, representing no one specifically) thoughts:
|
If I understand correctly, this would mean devs would need to do the following in Safari, correct? div[tabindex]:focus {
outline: 4px dashed orange; // strong keyboard focus indicator
}
div[tabindex]:focus:not(:focus-visible) {
outline: none; // hide focus on mouse click
} |
@bkardell wrote:
It's no secret that I wonder if the design of If that workaround had arisen, would we instead be talking about a new CSS property (maybe |
Would that also be possible with the pseudo class argument that Brian mentioned?
Another thing I'm curious about... The original intent of this issue was to point out that Chrome and Firefox's hiding of the focus ring on
I totally get why this makes sense, and would not be opposed to changing the behavior in Chrome if other folks on the Chrome team are supportive of it. But I'm a bit confused why this bullet would apply to |
No. My [Disclaimer: unvetted, brainstorm] suggestion of The goal would be to give authors a way to specify that As you mentioned later, this behavior could also extend to the user agent stylesheets for Firefox and Chrome on Mac, so that they could match the Mac behavior convention. Web authors could also use
Yes. In order to match the Mac UI convention, a mouse-click on In the case of |
We intentionally moved away from the Mac convention in here, fwiw: https://bugzilla.mozilla.org/show_bug.cgi?id=1614658#c15 |
Thank you for sharing that thread @emilio, it's a really great discussion! The gov.uk example in that thread makes a good argument for browsers to move focus to controls that don't receive text input, while also deciding internally to not draw a focus ring. The reason this seems useful is twofold:
So in the gov.uk case, where they want Windows-like behavior (even on macOS) they could say: input[type=radio]:focus {
outline: 2px solid orange; /* All radios get a custom outline, regardless of input device */
} But if another developer prefers using the macOS behavior on all platforms they could do: input[type=radio]:focus-visible {
outline: 2px solid orange; /* Radios only get a custom outline when navigated via keyboard */
} ** Edit ** Bit of a forehead slap moment when I remembered to scroll up and reread James' initial points that doing this also can create user confusion around how the spacebar and arrow keys work. Tricky... |
If the inputs were different, the outputs might have been different. The web's facilities for dealing with 'focus' are imo kind of a load bearing pile of ages old problematic things that need major investments in improving. Yes, there are lots of things worth exploring. Some don't even require changes to specs. Chrome's simultaneous introduction of a 'Quick Focus Highlight' mode is, I think a great example of an innovation that neatly seems to help a whole lot of things: it is always on top (kind of more like things provided by VO or whatever), it has a dual (consistent) ring which helps it be visible anywhere and it's non-distracting in significant ways without all this baggage. It isn't possible today to express the thing that mac buttons do. Should it be? Probably yes? Is a solution to that fundamentally necessary to provide before we can resolve on a useful focus-visible - I don't think so. If for no other reason: the current state of things does exist and mountains of content exist today that will be restyled for years to come in pretty much current form. That means, I think, we have to answer what to do with div tabindex=0 in terms of focus-visible. I mean, realistically I think we shouldn't speculate on whether people would use such a thing if it existed. As I see it, some pragamtic options are: a) :focus-visible matches that on click on mac and not elsewhere. It is hard for me to resolve this even in my head tbh. a tabindex=0 div doesn't seem to have a clear parallel.. It is itself is today, even on mac, more windows-like, so it's hard for me to even compare. Since that is all that exists the net result of too many sites just broadly disabling it seems bad/worse than edge cases. My biggest worry really is that a) leaves enough holes (despite our best hopes, divs with tabindexes abound) as to wind up in the same spot. |
Yeah this is my concern as well... Ultimately I want to give devs good flexibility to differentiate between mouse and keyboard focus without needing to resort to weird javascript hacks and/or having them nuke focus altogether.
This is an interesting idea. While I like that option-B gives folks flexibility to differentiate between mouse and keyboard focus, I'm worried that it may lead to webkit bug reports as people will see the default focus ring and assume :focus-visible should match. I guess you could also do option b while you work out how option c would actually work? 🤷♂️ |
I think that's the key point that I'm hearing from others inside Apple. We want interoperability, but this (both getting focus on click, and then hiding it) is fundamentally different from the platform experience UI expectation on Mac. Emilio's link states that Firefox on Mac chose to do this in order to 1) Match Windows/Linux, and 2) Match Chrome on Mac, which itself doesn't match the Mac convention. Now Safari is the only browser on Mac that behaves like most Mac users expect... |
FWIW, Chrome's settings have other platform-specific focus exceptions in them... Such as: chrome://settings/appearance "Pressing Tab on a webpage highlights links, as well as form fields" (On means "work more like Safari") chrome://settings/accessibility "Navigate pages with a text cursor" (On means "work more like Firefox and Windows") |
One example I have not seen discussed is the default Space Bar behavior when an activatable element is focused.
<button>
is tab-focused or script-focused, a visible focus ring is displayed and Space Bar in Safari will activate the button.<button>
is clicked, it does not receive keyboard focus from the click. The resulting state matches the user expectation that the button is not focused, it shows no focus outline , and therefore Space Bar will scroll the page.<div tabindex="0" role="button">
is click-focused, if the button remains focused but the focus ring is hidden, there is a user interface disconnect as to what Space Bar will do. Does it activate the button again (it will), or scroll down (as a user familiar with the Mac conventions would expect, since no focus ring is visible)?Similarly up/down arrow keys scroll the page by default, but modify certain controls (an slider, for example) when the control gets keyboard focused. The same is not true when these controls are modified with the mouse, as keyboard focus never moves to the control.
From a related thread:
The text was updated successfully, but these errors were encountered: