Skip to content

feat(ios): add subtitle support for UIMenu header button submenus#4107

Open
andreavrr wants to merge 1 commit into
software-mansion:mainfrom
andreavrr:feat/uimenu-subtitle-support
Open

feat(ios): add subtitle support for UIMenu header button submenus#4107
andreavrr wants to merge 1 commit into
software-mansion:mainfrom
andreavrr:feat/uimenu-subtitle-support

Conversation

@andreavrr
Copy link
Copy Markdown

Description

UIMenuElement.subtitle is a writable property available since iOS 15. This adds support for setting a subtitle on UIMenu (submenus) in header bar button items, mirroring the existing subtitle support already present for UIAction items (added in #3396).

The approach is straightforward: after creating the UIMenu via the existing initializer, we assign menu.subtitle if the subtitle key is present in the config dictionary.

UIMenu *menu = [UIMenu menuWithTitle:...];
NSString *subtitle = dict[@"subtitle"];
if (subtitle != nil && @available(iOS 15.0, *)) {
  menu.subtitle = subtitle;
}
return menu;

TypeScript: adds subtitle?: string to HeaderBarButtonItemSubmenu.

Use case

Showing the currently selected filter value below a submenu label — the same pattern used in Apple's own apps (e.g. Photos).

Changes

  • ios/RNSBarButtonItem.mm — assign subtitle on UIMenu after creation (iOS 15+)
  • src/types.tsx — add subtitle?: string | undefined to HeaderBarButtonItemSubmenu

Checklist

  • Included code example that can be used to test this change
  • Updated TS types

UIMenuElement.subtitle is a writable property available since iOS 15.
This patch reads the 'subtitle' key from the menu item dictionary and
assigns it after UIMenu creation, mirroring the existing subtitle support
already present for UIAction items.

Closes: adds subtitle to HeaderBarButtonItemSubmenu TypeScript type.
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