Skip to content

feat: Complete FAB Menu behavior and web adaptation - #5170

Open
alpharius-ck wants to merge 22 commits into
mainfrom
refactor-fab
Open

alpharius-ck wants to merge 22 commits into
mainfrom
refactor-fab

Conversation

@alpharius-ck

@alpharius-ck alpharius-ck commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

FAB.Menu did not follow the Material 3 spec or the other v6 components in a few ways. On web it did not tell assistive technology whether it was open. Collapsed items stayed in the tab order and the accessibility tree. Items had no hover, focus or press feedback, and a menu taller than the screen could not scroll.

This PR fixes those. Dismissal (Escape, Android back, outside press, screen reader escape) and focus handling (focus on open, restore on close) are intentionally left out and belong to the overlay work in #5127. A follow-up will wire FAB.Menu into that portal stack. Until then, the menu closes only through its trigger and items, as on main.

Builds on #5110 (variant rename). It also covers the aria-expanded change from #5151, so one of the two should be dropped when they land.

Related issue

https://app.notion.com/p/callstack/Complete-FAB-Menu-behavior-and-web-adaptation-3ac5d027c0f8806ba4f8f5a8cc061eac?v=3285d027c0f880a68ccb000c1ce3c56e&source=copy_link

Screenshots / Videos

fab-ios fab-general fab-android fab-web

Test plan

Use the example app: FAB → menu (yarn example web, yarn example ios, yarn example android).

Web

  1. In dev tools, the closed trigger has aria-expanded="false" and aria-haspopup="menu". After opening, it has aria-expanded="true", and the items container has role="menu".
  2. With the menu closed, Tab does not stop on any item. With it open, Tab reaches the items.
  3. With focus on an item, ArrowUp/ArrowDown, Home and End move focus through the items and then the close button, and wrap around. Arrow keys do nothing when focus is outside the menu.
  4. Hover, keyboard-focus and press an item. The state layer and elevation change. The focus ring appears for keyboard focus only, not mouse clicks. The state resets after the menu closes.
  5. Shrink the window height so the items don't fit. They scroll, the close button stays reachable, and the scroll position returns to the top each time the menu opens.

iOS / Android

  1. On a short screen or in landscape (Android: adb shell wm size 1080x1000), the items scroll to the last one. Reopening starts at the top.
  2. With VoiceOver or TalkBack on, collapsed items are not announced. Expanded items are announced, and the trigger is announced as expanded or collapsed.
  3. Press and hold an item (touch), or hover it on iPad with a pointer. The state layer shows and clears.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Found potential problems with the pull request:

  • The description is too long. Please keep it under 1000 characters.

alpharius-ck and others added 4 commits November 5, 2026 17:01
# Conflicts:
#	src/components/FAB/Shell.tsx
The previous merge of main kept the old versions of most files that
changed on main. Bring the tree to main plus the FAB menu changes so the
PR only shows the FAB files.

Type the FAB refs with ComponentRef<typeof View> and
ComponentRef<typeof ScrollView>, as main does, since View and ScrollView
are no longer instance types on React Native 0.88.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Doberjohn

Copy link
Copy Markdown
Collaborator

Thanks for the videos @likevy, they look good. After I updated the branch, Typecheck and Build package fail: React Native 0.88 (from #5167) now types onKeyDown and onKeyUp on View and Pressable with its own key event, so the React DOM KeyboardEvent in useSpaceKeyPress no longer fits. Replacing it with only what the handlers read fixes it and passes the legacy types check too:

type KeyboardEvent = {
  nativeEvent: { key: string; repeat?: boolean | undefined };
  preventDefault: () => void;
};

Could you push that? Then I'll do the last checks and merge.

@alpharius-ck

Copy link
Copy Markdown
Collaborator Author

Thanks for the videos @likevy, they look good. After I updated the branch, Typecheck and Build package fail: React Native 0.88 (from #5167) now types onKeyDown and onKeyUp on View and Pressable with its own key event, so the React DOM KeyboardEvent in useSpaceKeyPress no longer fits. Replacing it with only what the handlers read fixes it and passes the legacy types check too:

type KeyboardEvent = {
  nativeEvent: { key: string; repeat?: boolean | undefined };
  preventDefault: () => void;
};

Could you push that? Then I'll do the last checks and merge.

sure - would do asap

@alpharius-ck

Copy link
Copy Markdown
Collaborator Author

@Doberjohn branch is working correctly with RN 0.88

alpharius-ck and others added 3 commits November 16, 2026 09:37
Resolve FAB.Menu against the shared `useFocusRing` from main, and make the
menu a proper overlay: Escape, Android back and the iOS escape gesture
dismiss it, focus moves to the first item on open and returns to the
trigger on close.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@jacekAtCK jacekAtCK left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the rebase on main and the keyboard issues on web. Details are inline.

Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/Shell.tsx Resolved
Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/tokens.ts Resolved
@Doberjohn Doberjohn added this to the 6.0.0 milestone Nov 19, 2026
Resolve the FAB conflicts with main: the trigger ref now feeds both the
caller's `buttonRef` and the web focus handling, and the menu items drop
`theme.animation.scale`, which main removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on c80b74e. The verdict and the full list are in the summary comment.

Comment thread src/components/FAB/Menu.tsx Resolved
Comment thread src/components/FAB/Menu.tsx Resolved
@apex-sentinel-staging

This comment has been minimized.

- Press an item with Space on web, as Checkbox does.
- Give the open menu one tab stop on web that the arrow keys move, keep the
  arrow keys among the items, and name the menu after its trigger.
- Call onDismiss when the trigger hides while the menu is open.
- Stop documenting that an outside press closes the menu.
- Move webNoHoverTint into Menu and remove the unused FAB/focus helper.
- Check the focused element in the focus tests without a cast.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on ec37952. The verdict and the full list are in the summary comment.

Comment thread src/components/FAB/Menu.tsx Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

Move the choice of the next item into getNextStopIndex, test it for the
arrow keys, Home and End, and test that the menu listens for the arrow keys
only while it is open.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

Comment thread src/components/FAB/Menu.tsx Resolved
Without a trigger aria-label the menu had no accessible name, so the items
are plain buttons then. Also list every onDismiss route in the migration guide.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 01a6667. The verdict and the full list are in the summary comment.

Comment thread src/components/FAB/Menu.tsx Resolved
The trigger always set aria-haspopup="menu", even when the items were plain
buttons because the trigger had no aria-label. Gate it on the same condition
as role="menu".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

Comment thread src/components/FAB/Menu.tsx Resolved
@apex-sentinel-staging

This comment has been minimized.

The item drew its own pressed state layer on top of the TouchableRipple
ripple, so it showed with the ripple effect turned off and stacked with the
ripple when on. Keep the flat layer for hover and focus only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

The press ripple was the neutral default while the hover and focus layers use
the item's content color. Use getRippleColorFromContent, as Button and
IconButton do.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of ce0e35d

Since the review of 91cfc27: 0 new · 0 still open · 0 no longer raised

No open findings.

Not in the reviewers' prompt (5 files)
  • docs/public/screenshots/fab-android.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/fab-general.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/fab-ios.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/fab-web.png: no text diff (a binary, empty or mode-only change)
  • src/components/__tests__/__snapshots__/FABMenu.test.tsx.snap: generated or a lockfile, so its lines were left out

Reviewed with this repository's own Sentinel configuration (8cf0688deadc).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants