Skip to content

fix(menu): enable FocusZone in MenuList on react-native-windows - #4367

Open
udit (UditDewan) wants to merge 2 commits into
microsoft:mainfrom
UditDewan:fix/menulist-windows-focuszone
Open

udit (UditDewan) wants to merge 2 commits into
microsoft:mainfrom
UditDewan:fix/menulist-windows-focuszone

Conversation

@UditDewan

Copy link
Copy Markdown

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

Description of changes

Fixes #4174.

MenuList only rendered its focusZone slot as a FocusZone on macos and win32. On react-native-windows the slot fell back to a plain View, so there was no container-level roving focus and menu items were reachable only with Tab.

@fluentui-react-native/native-core now ships a Fabric FocusZone for windows (#4354) that handles focusZoneDirection, navigateAtEnd, tabKeyNavigation, and Home/End keys, so this enables it for windows as well:

  • packages/components/Menu/src/MenuList/MenuList.tsx: add 'windows' to shouldHaveFocusZone. The existing props passed to the focus zone (focusZoneDirection: 'vertical', enableFocusRing: false, tabKeyNavigation: 'None') now apply on windows too. Circular navigation and focus-on-container behavior are unchanged (still win32-only / macOS-only respectively).
  • MenuList.types.ts: update the slot comment.
  • Added a patch changeset for @fluentui-react-native/menu.

Verification

  • yarn build, yarn lint and yarn test for @fluentui-react-native/menu (all platforms' Jest suites pass), yarn format:check.
Before After
On windows, Up/Down/Home/End do nothing inside an open menu; items reachable only via Tab Arrow keys move between menu items vertically, Home/End jump to first/last, matching win32/macOS

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

MenuList only used FocusZone on macOS and win32, so on windows the
focusZone slot fell back to a plain View and menu items could only be
reached with Tab. Now that native-core ships a Fabric FocusZone for
windows, enable it there too so Up/Down/Home/End navigation works.

Fixes microsoft#4174
@JasonVMo

Copy link
Copy Markdown
Contributor

Please merge or rebase the latest changes from main to fix the test repo links test. This was caused by rnx-kit changing its documentation layout and should be already fixed in main.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle size report

Tree-shaken, minified production esbuild bundles with React and React Native runtimes externalized.

Scenario Modules-Mac (Δ) Modules-Win (Δ) Size-Mac (Δ) Size-Win (Δ)
components-button 62 (+0) 63 (+0) 49.94k (+0b) 49.87k (+0b)
components-catalog 159 (+0) 160 (+0) 155.26k (+0b) 155.19k (+0b)
design-theme-state 33 (+0) 34 (+0) 30.11k (+0b) 30.03k (+0b)
design-themed-root 37 (+0) 38 (+0) 32.07k (+0b) 32.00k (+0b)
design-color-lib 6 (+0) 6 (+0) 6.33k (+0b) 6.33k (+0b)
design-theme-state-legacy-source 34 (+0) 35 (+0) 31.77k (+0b) 31.69k (+0b)
design-legacy-theme-from-flex 57 (+0) 58 (+0) 97.72k (+0b) 97.59k (+0b)

The job is advisory: size changes are reported but do not fail the pull request. Bundle or analysis errors still fail.


View bundle-size workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MenuList: FocusZone not wired for react-native-windows ('windows'), so menu items are Tab-only (no arrow-key roving focus)

2 participants