microsoft / keyborg

A library that tracks browser keyboard focus state that powers tabster
MIT License
13 stars 5 forks source link

iOS touch events do not properly remove focus rectangle #79

Closed micahgodbolt closed 2 weeks ago

micahgodbolt commented 3 weeks ago

In iOS, if isNavigatingWithKeyboard is set to true via attached keyboard or a focus event outside of the _isMouseUsedTimer, then _onMouseDown will not set isNavigatingWithKeyboard back to false because it will get caught in the following return exception:

https://github.com/microsoft/keyborg/blob/main/src/Keyborg.ts#L164

Turns out that Android and Windows touch events mimic mouse events and pass a buttons of 1, but iOS touch events have a buttons value of 0, which causes the touch to be treated like a screen reader event.

smhigley commented 3 weeks ago

Just as an addendum here, we also need to make sure iOS + bluetooth keyboard maintains focus outlines, since I think that's the line enabling that behavior now.

Also windows desktop SRs in scan mode/virtual cursor don't currently show focus outlines, even with that check. VoiceOver on macOS does rely on that check, though is somewhat less important since it has its own cursor outline & generally users are not encouraged to use the tab key.

smhigley commented 3 weeks ago

My suggestion for how to proceed, based on BizChat wanting this fixed quickly as a ship-blocker would be:

  1. remove the buttons: 0 heuristic entirely for now. Maybe also the clientX/clientY/etc heuristic too, since at a quick glance that didn't seem to be catching any modern SRs.
  2. Look into adding :focus-visible as a focus selector in addition to the tabster data attribute (i.e. so the focus style shows if either the data attribute is present, or :focus-visible matches) in @fluentui/react-tabster

The second one would help us have more robust focus styles in general, and get us out of the trap of trying to use heuristics to detect ATs. That way the data attribute is primarily a fallback for browsers that don't support focus-visible yet

micahgodbolt commented 2 weeks ago

fixed #80