Skip to content

feat(android): support displayInline - #1266

Merged
Naturalclar merged 1 commit into
react-native-menu:masterfrom
zewish:master
Dec 2, 2026
Merged

Naturalclar merged 1 commit into
react-native-menu:masterfrom
zewish:master

Conversation

@zewish

@zewish zewish commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Fixes dividers for #1134 and connected to #271.

Found this while building a menu with a group of checkable items. On iOS displayInline shows the group right in the menu and it looks great. On Android it's ignored, so the same group ends up in a sub menu.

<MenuView
  actions={[
    { id: 'rename', title: 'Rename' },
    {
      title: 'Sort by',
      displayInline: true,
      subactions: [
        { id: 'name', title: 'Name', state: 'on' },
        { id: 'date', title: 'Date', state: 'off' },
      ],
    },
    { id: 'delete', title: 'Delete', attributes: { destructive: true } },
  ]}
>
  <Text>Open menu</Text>
</MenuView>

Old behavior:

  • "Sort by" opens a sub menu

New behavior:

  • "Sort by" is a title and its items are right below it, with dividers around the group
Old Old (sub menu) New
Light before-light-menu before-light-submenu after-light-menu
Dark before-dark-menu before-dark-submenu after-dark-menu

The rounded corners come from the theme of our app.

NOTE: Android menus that already use displayInline: true will look different, because they showed a sub menu until now. iOS is not affected since it already supports this.

Implementation details:

  • Dividers need Android API 28+. Older versions get the same menu without them.

Test Plan

  1. Run the example app on Android and open the "Test" menu
  2. "Inline Actions" is a title with two items below it and dividers around them
  3. Press one of the two items - onPressAction gets its id

Tested in our app on an Android 16 emulator in light and dark mode (screenshots above) and on an Android 8 emulator.

@zewish
zewish requested a review from Naturalclar as a code owner November 25, 2026 06:49
@zewish

zewish commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Hey @Naturalclar, any chance you could look at this one? It's a fairly small one, but a very annoying because of the inconsistencies of looks between the two platforms.

@Naturalclar Naturalclar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution!

@Naturalclar
Naturalclar merged commit 379e7ec into react-native-menu:master Dec 2, 2026
6 checks passed
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.

2 participants