feat(android): add androidDisplayMode prop for tooltip/dialog menu style#9
Merged
sbaiahmed1 merged 2 commits intomainfrom Dec 6, 2025
Merged
feat(android): add androidDisplayMode prop for tooltip/dialog menu style#9sbaiahmed1 merged 2 commits intomainfrom
sbaiahmed1 merged 2 commits intomainfrom
Conversation
Reviewer's GuideAdds a new androidDisplayMode prop to allow Android menus to render as native tooltip-style PopupMenu instead of the existing dialog implementation, updates the Android native view/manager wiring, and extends the example app and README to document the new behavior and related props/features. Sequence diagram for Android menu display mode selectionsequenceDiagram
actor User
participant ReactNativeApp
participant MenuViewJS
participant MenuViewNativeComponent
participant MenuViewNative
participant AndroidPopupMenu
participant AndroidDialog
User->>ReactNativeApp: Tap menu trigger
ReactNativeApp->>MenuViewJS: onPress handler
MenuViewJS->>MenuViewNativeComponent: render with androidDisplayMode=tooltip
MenuViewNativeComponent->>MenuViewNative: setAndroidDisplayMode(tooltip)
User->>MenuViewNative: touch intercepted on trigger view
MenuViewNative->>MenuViewNative: showMenu()
alt androidDisplayMode == tooltip
MenuViewNative->>MenuViewNative: showTooltipMenu()
MenuViewNative->>AndroidPopupMenu: create PopupMenu and populate items
AndroidPopupMenu-->>User: show anchored tooltip menu
else androidDisplayMode == dialog
MenuViewNative->>MenuViewNative: showDialogMenu()
MenuViewNative->>AndroidDialog: create and show dialog
AndroidDialog-->>User: show bottom dialog menu
end
User->>AndroidPopupMenu: select item
AndroidPopupMenu->>MenuViewNative: onMenuItemClick
MenuViewNative->>MenuViewNativeComponent: dispatch onMenuSelect
MenuViewNativeComponent->>MenuViewJS: onMenuSelect event
MenuViewJS->>ReactNativeApp: handleMenuSelect and update state
Updated class diagram for MenuView Android display modes and propsclassDiagram
class MenuView {
- String androidDisplayMode
- List~ReadableMap~ menuItems
- String themeVariant
- String selectedItemIdentifier
+ setAndroidDisplayMode(mode String)
+ setMenuItems(items List~ReadableMap~)
+ setThemeVariant(themeVariant String)
+ setSelectedIdentifier(identifier String)
- void showMenu()
- void showTooltipMenu()
- void showDialogMenu()
}
class MenuViewManager {
+ createViewInstance(context ThemedReactContext) MenuView
+ setMenuItems(view MenuView, menuItems ReadableArray)
+ setSelectedIdentifier(view MenuView, selectedIdentifier String)
+ setDisabled(view MenuView, disabled Boolean)
+ setAndroidDisplayMode(view MenuView, androidDisplayMode String)
}
class NativeProps {
+ menuItems MenuItem[]
+ selectedIdentifier String
+ disabled Boolean
+ androidDisplayMode androidDisplayModeType
+ onMenuSelect BubblingEventHandler
}
class MenuItem {
+ identifier String
+ title String
+ subtitle String
+ destructive Boolean
+ iosSymbol String
}
class androidDisplayModeType {
<<enumeration>>
dialog
tooltip
}
MenuViewManager --> MenuView : manages
NativeProps --> MenuItem : uses
NativeProps --> androidDisplayModeType : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The new
androidDisplayModeprop isn’t documented in the README props table; consider adding it (including allowed values and default) so consumers know how to opt into the tooltip-style menu. - In
MenuView.setAndroidDisplayModeandshowMenu, the comments still refer to text color / items requesting tooltip mode, which no longer matches the implementation; updating these comments will make the behavior clearer to future readers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `androidDisplayMode` prop isn’t documented in the README props table; consider adding it (including allowed values and default) so consumers know how to opt into the tooltip-style menu.
- In `MenuView.setAndroidDisplayMode` and `showMenu`, the comments still refer to text color / items requesting tooltip mode, which no longer matches the implementation; updating these comments will make the behavior clearer to future readers.
## Individual Comments
### Comment 1
<location> `android/src/main/java/com/menu/MenuView.kt:184` </location>
<code_context>
private fun showMenu() {
+ // Check if any item requests tooltip mode
+ val useTooltip = androidDisplayMode == "tooltip"
+
+ if (useTooltip) {
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider normalizing/validating `androidDisplayMode` and fixing the minor formatting issue.
Any value other than the exact string "tooltip" (including typos) now silently falls back to dialog mode. To avoid subtle bugs, consider normalizing this value (e.g., trim/lowercase) and constraining it to known options (constants or an enum). Also, there’s a double space before `androidDisplayMode` that should be removed.
Suggested implementation:
```
androidDisplayMode = mode
?.trim()
?.lowercase()
?.takeIf { it == "tooltip" || it == "dialog" }
?: "dialog"
}
```
```
// Check if any item requests tooltip mode
val useTooltip = androidDisplayMode == "tooltip"
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
refactor(android): clean up androidDisplayMode related code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for tooltip-style menus on Android through new androidDisplayMode prop. This provides more native-like menu behavior on Android, matching platform conventions where appropriate.
The prop accepts either 'dialog' (default) or 'tooltip' mode. When set to 'tooltip', the menu appears as a native PopupMenu anchored to the trigger view, with proper theme support and destructive item styling.
Summary by Sourcery
Add configurable Android menu display modes and expand the documented MenuView API and examples.
New Features:
Enhancements:
Documentation: