Merged
Conversation
Reviewer's GuideThis PR refactors the iOS MenuView to rely on React for mounting and constraint management, ensures menu selection state persists across remounts by adding a dedicated updateMenuSelection method, introduces platform-specific rendering logic in the React wrapper, tidies example imports, and bumps the package version. Sequence diagram for menu selection state update on iOS remountsequenceDiagram
participant React
participant MenuView (iOS)
participant _menuButton
React->>MenuView (iOS): Remounts component
MenuView (iOS)->>MenuView (iOS): updateProps called
alt selectedIdentifier changed
MenuView (iOS)->>MenuView (iOS): updateMenuItems
else _menuButton and _menuButton.menu exist
MenuView (iOS)->>MenuView (iOS): updateMenuSelection
MenuView (iOS)->>_menuButton: Recreate menu with correct selection
end
Class diagram for updated MenuView (iOS) methodsclassDiagram
class MenuView {
- _menuItems: NSArray<NSDictionary *>
- _menuButton: UIButton
+ updateProps(props, oldProps)
+ updateMenuItems(menuItems, selectedIdentifier)
+ updateMenuSelection(selectedIdentifier)
+ selectMenuItem(identifier, title)
}
MenuView : updateMenuSelection(selectedIdentifier)
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 and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `ios/MenuView.mm:248-249` </location>
<code_context>
+ // Recreate the menu with updated selection states
+ NSMutableArray<UIAction *> *actions = [[NSMutableArray alloc] init];
+
+ for (UIMenuElement *element in _menuButton.menu.children) {
+ if ([element isKindOfClass:[UIAction class]]) {
+ UIAction *oldAction = (UIAction *)element;
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Recreating UIActions may lose other properties or behaviors set on the original actions.
Ensure all relevant properties from oldAction are copied to newAction to maintain expected behavior.
Suggested implementation:
```
for (UIMenuElement *element in _menuButton.menu.children) {
if ([element isKindOfClass:[UIAction class]]) {
UIAction *oldAction = (UIAction *)element;
// Copy all relevant properties from oldAction
NSString *title = oldAction.title;
UIImage *image = oldAction.image;
NSString *identifier = oldAction.identifier;
UIActionAttributes attributes = oldAction.attributes;
UIActionState state = [oldAction.identifier isEqualToString:selectedIdentifier] ? UIActionStateOn : UIActionStateOff;
NSString *discoverabilityTitle = oldAction.discoverabilityTitle;
UIActionHandler handler = oldAction.handler;
UIAction *newAction = [UIAction actionWithTitle:title
image:image
identifier:identifier
handler:handler];
newAction.attributes = attributes;
newAction.state = state;
newAction.discoverabilityTitle = discoverabilityTitle;
[actions addObject:newAction];
```
If your UIAction objects have other custom properties or behaviors, ensure those are also copied to the newAction. If you use custom subclasses of UIAction, you may need to copy those properties as well.
</issue_to_address>
### Comment 2
<location> `src/index.tsx:29-30` </location>
<code_context>
- <NativeMenuView ref={ref} {...nativeProps}>
- {children}
- </NativeMenuView>
+ <View style={styles.relative}>
+ <NativeMenuView
+ style={[
+ StyleSheet.absoluteFill,
</code_context>
<issue_to_address>
**issue (bug_risk):** Absolute positioning and zIndex may cause stacking or touch issues with children.
Please verify that NativeMenuView's absolute positioning and zIndex do not block or intercept touch events intended for its children, particularly in nested or complex layouts.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
e014f1f to
873fd65
Compare
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.
Summary by Sourcery
Fix iOS menu mounting by relying on React’s view hierarchy, removing conflicting constraints, and ensuring the menu’s selection state is correctly refreshed after remounts; introduce platform-specific rendering for MenuView and bump package version.
New Features:
Enhancements:
Build: