Skip to content

Use a custom context menu sheet on Android - #66

Open
lucaboox wants to merge 1 commit into
dmilin1:masterfrom
lucaboox:feat/android-context-menu
Open

lucaboox wants to merge 1 commit into
dmilin1:masterfrom
lucaboox:feat/android-context-menu

Conversation

@lucaboox

Copy link
Copy Markdown

useContextMenu carried a requestAnimationFrame workaround on Android to stop a second action sheet from silently failing to appear when two were opened back to back.

This replaces the action sheet on Android with a bottom sheet rendered by the app, which removes the need for that workaround and lets the menu show its title, message, disabled entries, destructive colouring, and an icon per row.

Notes

  • ContextMenuSheet owns the pending request itself and is shown through an imperative showContextMenu() call, so nothing is threaded through ActionSheetBgContext — which iOS also consumes. Those files are untouched.
  • Row icons are matched from the option label via a small regex table, falling back to a generic chevron. It's a heuristic and it will degrade to the fallback if labels are ever localized — happy to drop the icons entirely if you'd rather not carry that.

iOS

Unaffected. The sheet is mounted only on Android and the iOS branch of useContextMenu is unchanged.

Verification

tsc --noEmit and eslint are clean, and a release build was installed and exercised on a physical device (Android 17, arm64).

🤖 Generated with Claude Code

The Android action sheet from @expo/react-native-action-sheet needed a
requestAnimationFrame workaround in useContextMenu to stop a second sheet
from silently failing to appear when two were opened back to back.

This replaces it on Android with a bottom sheet rendered by the app, which
removes the need for that workaround and lets the menu show its title,
message, disabled entries, destructive colouring, and an icon per row.

ContextMenuSheet owns the pending request itself and is shown through an
imperative showContextMenu() call, so nothing has to be threaded through
the action sheet context that iOS also consumes. It is mounted only on
Android, and the iOS path in useContextMenu is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant