Skip to content

Commit 5b7ab17

Browse files
committed
fix(menu): enhance menu action handling in updateMenuSelection method
1 parent bae480c commit 5b7ab17

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ios/MenuView.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,29 @@ - (void)updateMenuSelection:(NSString *)selectedIdentifier
249249
if ([element isKindOfClass:[UIAction class]]) {
250250
UIAction *oldAction = (UIAction *)element;
251251

252+
// Create new action with handler that captures the identifier and title
252253
UIAction *newAction = [UIAction actionWithTitle:oldAction.title
253254
image:oldAction.image
254255
identifier:oldAction.identifier
255256
handler:^(__kindof UIAction * _Nonnull action) {
256257
[self selectMenuItem:action.identifier title:action.title];
257258
}];
258259

260+
// Copy all relevant properties from oldAction to preserve behavior
261+
newAction.attributes = oldAction.attributes;
262+
259263
// Update state based on current selection
260264
if (selectedIdentifier != nil && ![selectedIdentifier isEqualToString:@""] && [oldAction.identifier isEqualToString:selectedIdentifier]) {
261265
newAction.state = UIMenuElementStateOn;
262266
} else {
263267
newAction.state = UIMenuElementStateOff;
264268
}
265269

270+
// Copy discoverability title if present
271+
if (oldAction.discoverabilityTitle) {
272+
newAction.discoverabilityTitle = oldAction.discoverabilityTitle;
273+
}
274+
266275
[actions addObject:newAction];
267276
}
268277
}

0 commit comments

Comments
 (0)