-
-
Notifications
You must be signed in to change notification settings - Fork 613
Open
Labels
Missing reproThis issue need minimum repro scenarioThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOSThis issue is specific to iOS
Description
Description
When using multiple menus in unstable_headerRightItems, selecting an item from one menu triggers the handler from a different menu at the same index position. For example, selecting the first item in Menu A triggers the handler for the first item in Menu B.
Menu item handlers appear to be stored in a flat array, causing index collisions between different menus.
Workaround: Moving one menu to unstable_headerLeftItems resolves the issue, since left and right items appear to have separate handler arrays. Adding identifier properties to menu items did not resolve the issue.
Steps to reproduce
- Create a screen with two menus in
unstable_headerRightItems:
navigation.setOptions({
unstable_headerRightItems: () => [
{
type: "menu",
label: "Filter",
icon: { type: "sfSymbol", name: "line.3.horizontal.decrease" },
menu: {
items: [
{
type: "action",
label: "Sort by date",
onPress: () => console.log("Sort by date"), // Index 0 in Menu 1
},
{
type: "action",
label: "Sort by name",
onPress: () => console.log("Sort by name"), // Index 1 in Menu 1
},
],
},
},
{
type: "menu",
label: "Add",
icon: { type: "sfSymbol", name: "plus" },
menu: {
items: [
{
type: "action",
label: "Import from URL",
onPress: () => console.log("Import URL"), // Index 0 in Menu 2
},
{
type: "action",
label: "Enter manually",
onPress: () => console.log("Enter manually"), // Index 1 in Menu 2
},
],
},
},
],
});- Open the Filter menu and tap "Sort by date"
- Observe that "Import URL" is logged instead of "Sort by date"
Snack or a link to a repository
No response
Screens version
4.19.0
React Native version
0.81.5
Platforms
iOS
JavaScript runtime
Hermes
Workflow
Expo
Architecture
New Architecture
Build type
Debug mode
Device
iOS simulator
Device model
No response
Acknowledgements
Yes
Metadata
Metadata
Assignees
Labels
Missing reproThis issue need minimum repro scenarioThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOSThis issue is specific to iOS