microsoft / fluentui-react-native

A react-native component library that implements the Fluent Design System.
https://developer.microsoft.com/fluentui
MIT License
1.25k stars 161 forks source link

[Mac] [Focus Zone] Tweak tab\shift behavior #3690

Closed nakambo closed 1 month ago

nakambo commented 1 month ago

Platforms Impacted

Description of changes

In a previous commit, I added tabKeyNavigation behavior. However, it ultimately relied on translating the tab\shift+tab action into arrow keys to figure out which view to focus. It didn't occur to me before though that arrow keys CAN behave differently depending on whether they're horizontal or vertical (easily observable when the focus zone controls are not all laid out on a single row or column), and there might be scenarios where either don't behave right, especially with circular navigation.

I also noticed arrow key behaviors (including the non-circular cases) as implemented on macOS are different in the Win32 (Office) version AND the web version of Fluent. But this change doesn't aim to address only of that. In this change we will only update tab\shift+tab to behave like the system key view loop, which should provide a more predictable behavior than arrow keys.

Verification

Manual testing:

Old behavior: https://github.com/user-attachments/assets/657a760d-4132-4513-8247-a913d75dfec7 New behavior: https://github.com/user-attachments/assets/3d5a0bd1-5606-4d9f-866c-e265e49142e1

Pull request checklist

This PR has considered (when applicable):