Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

@react-native-menu__menu@2.0.0.patch

515 lines23.6 KB

1diff --git a/ios/MenuViewManager.mm b/ios/MenuViewManager.mm
2index 3d149b3e7426b8f7c999603ddf1e15e12331c33a..e80fe2caae86e339fcb03408419a7d64b3e5b04f 100644
3--- a/ios/MenuViewManager.mm
4+++ b/ios/MenuViewManager.mm
5@@ -65,6 +65,10 @@ - (UIView *)view
6 * onOpenMenu: callback to be called when the menu is opened
7 */
8 RCT_EXPORT_VIEW_PROPERTY(onOpenMenu, RCTDirectEventBlock);
9+/**
10+ * onMenuInteractionStart: callback to be called when UIKit starts preparing a menu interaction
11+ */
12+RCT_EXPORT_VIEW_PROPERTY(onMenuInteractionStart, RCTDirectEventBlock);
13 /**
14 * shouldOpenOnLongPress: determines whether menu should be opened after long press or normal press
15 */
16diff --git a/ios/NewArch/FabricActionSheetView.swift b/ios/NewArch/FabricActionSheetView.swift
17index 484ff8a1d73a6d445273883c5b28b1c8e80901ec..bc92310d00369b853a80f4d2080578f3903191d2 100644
18--- a/ios/NewArch/FabricActionSheetView.swift
19+++ b/ios/NewArch/FabricActionSheetView.swift
20@@ -3,6 +3,7 @@ public class FabricActionSheetView: ActionSheetView, FabricViewImplementationPro
21 public var onPressAction: ((String) -> Void)?
22 public var onCloseMenu: (() -> Void)?
23 public var onOpenMenu: (() -> Void)?
24+ public var onMenuInteractionStart: (() -> Void)?
26 @objc override func sendButtonAction(_ action: String) {
27 if let onPress = onPressAction {
28diff --git a/ios/NewArch/FabricMenuViewImplementation.swift b/ios/NewArch/FabricMenuViewImplementation.swift
29index 33d27c5a66593ae1a9b143804413578eb79f1a7d..359cd19fa53d10c0374b2b537517ea8629e79d0c 100644
30--- a/ios/NewArch/FabricMenuViewImplementation.swift
31+++ b/ios/NewArch/FabricMenuViewImplementation.swift
32@@ -12,6 +12,7 @@ public class FabricMenuViewImplementation: MenuViewImplementation, FabricViewImp
33 public var onPressAction: ((String) -> Void)?
34 public var onCloseMenu: (() -> Void)?
35 public var onOpenMenu: (() -> Void)?
36+ public var onMenuInteractionStart: (() -> Void)?
38 @objc override func sendButtonAction(_ action: UIAction) {
39 if let onPress = onPressAction {
40@@ -31,4 +32,10 @@ public class FabricMenuViewImplementation: MenuViewImplementation, FabricViewImp
41 }
42 }
44+ @objc override func sendMenuInteractionStart() {
45+ if let onMenuInteractionStart = onMenuInteractionStart {
46+ onMenuInteractionStart()
47+ }
48+ }
50 }
51diff --git a/ios/NewArch/FabricViewImplementationProtocol.swift b/ios/NewArch/FabricViewImplementationProtocol.swift
52index 2cef2fb8c74497da46775a490edc58cf8cbf29cc..54429c756eeecf6e96b55d62cc1e70213096f62a 100644
53--- a/ios/NewArch/FabricViewImplementationProtocol.swift
54+++ b/ios/NewArch/FabricViewImplementationProtocol.swift
55@@ -8,4 +8,5 @@ import Foundation
56 var onPressAction: ((String) -> Void)? { get set }
57 var onCloseMenu: (() -> Void)? { get set }
58 var onOpenMenu: (() -> Void)? { get set }
59+ var onMenuInteractionStart: (() -> Void)? { get set }
60 }
61diff --git a/ios/NewArch/MenuView.mm b/ios/NewArch/MenuView.mm
62index a54e619eb39e3402fa63f2ee4f734063d4f8fc58..773f6f1f5d4e0663fd3211fe51085a7f3935e445 100644
63--- a/ios/NewArch/MenuView.mm
64+++ b/ios/NewArch/MenuView.mm
65@@ -46,6 +46,10 @@ - (instancetype)initWithFrame:(CGRect)frame
66 [self onOpenMenu];
67 };
69+ _view.onMenuInteractionStart = ^{
70+ [self onMenuInteractionStart];
71+ };
73 _view.onCloseMenu = ^{
74 [self onCloseMenu];
75 };
76@@ -92,6 +96,14 @@ - (void)onOpenMenu {
77 }
78 }
80+- (void)onMenuInteractionStart {
81+ // If screen is already unmounted then there will be no event emitter
82+ const auto eventEmitter = [self getEventEmitter];
83+ if (eventEmitter != nullptr) {
84+ eventEmitter->onMenuInteractionStart({});
85+ }
86+}
88 /**
89 Responsible for iterating through the C++ vector<struct> and convert each struct element to NSDictionary, then return it all in an NSArray
90 */
91@@ -105,6 +117,27 @@ - (void)onOpenMenu {
92 NSMutableArray<NSDictionary *> *subactionsArray = [NSMutableArray arrayWithCapacity:actions.size()];
93 if (action.subactions.size() > 0) {
94 for (const MenuViewActionsSubactionsStruct &subaction : action.subactions) {
95+ NSMutableArray<NSDictionary *> *subSubactionsArray =
96+ [NSMutableArray arrayWithCapacity:subaction.subactions.size()];
97+ for (const MenuViewActionsSubactionsSubactionsStruct &subSubaction : subaction.subactions) {
98+ NSDictionary *subSubactionDict = @{
99+ @"id": [NSString stringWithUTF8String:subSubaction.id.c_str()],
100+ @"title": [NSString stringWithUTF8String:subSubaction.title.c_str()],
101+ @"titleColor": @(subSubaction.titleColor),
102+ @"subtitle": [NSString stringWithUTF8String:subSubaction.subtitle.c_str()],
103+ @"state": [NSString stringWithUTF8String:subSubaction.state.c_str()],
104+ @"image": [NSString stringWithUTF8String:subSubaction.image.c_str()],
105+ @"imageColor": @(subSubaction.imageColor),
106+ @"displayInline": @(subSubaction.displayInline),
107+ @"attributes": @{
108+ @"destructive": @(subSubaction.attributes.destructive),
109+ @"disabled": @(subSubaction.attributes.disabled),
110+ @"hidden": @(subSubaction.attributes.hidden),
111+ @"keepsMenuPresented": @(subSubaction.attributes.keepsMenuPresented),
112+ },
113+ };
114+ [subSubactionsArray addObject:subSubactionDict];
115+ }
116 NSDictionary *subactionDict = @{
117 @"id": [NSString stringWithUTF8String:subaction.id.c_str()],
118 @"title": [NSString stringWithUTF8String:subaction.title.c_str()],
119@@ -118,7 +151,9 @@ - (void)onOpenMenu {
120 @"destructive": @(subaction.attributes.destructive),
121 @"disabled": @(subaction.attributes.disabled),
122 @"hidden": @(subaction.attributes.hidden),
123+ @"keepsMenuPresented": @(subaction.attributes.keepsMenuPresented),
124 },
125+ @"subactions": subSubactionsArray,
126 };
127 [subactionsArray addObject:subactionDict];
128 }
129@@ -138,6 +173,7 @@ - (void)onOpenMenu {
130 @"destructive": @(action.attributes.destructive),
131 @"disabled": @(action.attributes.disabled),
132 @"hidden": @(action.attributes.hidden),
133+ @"keepsMenuPresented": @(action.attributes.keepsMenuPresented),
134 },
135 @"subactions": subactionsArray,
136 };
137diff --git a/ios/OldArch/LegacyActionSheetView.swift b/ios/OldArch/LegacyActionSheetView.swift
138index 3cd1a2517624d99b51331c564fba9145d7c8d799..e458504bea6ef167d9b0db0c889f0f76ea965287 100644
139--- a/ios/OldArch/LegacyActionSheetView.swift
140+++ b/ios/OldArch/LegacyActionSheetView.swift
141@@ -3,6 +3,7 @@ public class LegacyActionSheetView: ActionSheetView {
142 @objc var onPressAction: RCTDirectEventBlock?
143 @objc var onCloseMenu: RCTDirectEventBlock?
144 @objc var onOpenMenu: RCTDirectEventBlock?
145+ @objc var onMenuInteractionStart: RCTDirectEventBlock?
149diff --git a/ios/OldArch/LegacyMenuViewImplementation.swift b/ios/OldArch/LegacyMenuViewImplementation.swift
150index 6a2a205f95c1001f3fdf6fb835815fa7c4c02c16..4f42b64349966fb1438f72439cec8256a76aab9c 100644
151--- a/ios/OldArch/LegacyMenuViewImplementation.swift
152+++ b/ios/OldArch/LegacyMenuViewImplementation.swift
153@@ -5,6 +5,7 @@ public class LegacyMenuViewImplementation: MenuViewImplementation {
154 @objc var onPressAction: RCTDirectEventBlock?
155 @objc var onCloseMenu: RCTDirectEventBlock?
156 @objc var onOpenMenu: RCTDirectEventBlock?
157+ @objc var onMenuInteractionStart: RCTDirectEventBlock?
159 @objc override func sendButtonAction(_ action: UIAction) {
160 if let onPress = onPressAction {
161@@ -24,4 +25,10 @@ public class LegacyMenuViewImplementation: MenuViewImplementation {
162 }
163 }
165+ @objc override func sendMenuInteractionStart() {
166+ if let onMenuInteractionStart = onMenuInteractionStart {
167+ onMenuInteractionStart([:])
168+ }
169+ }
171 }
172diff --git a/ios/Shared/MenuViewImplementation.swift b/ios/Shared/MenuViewImplementation.swift
173index 5c4e0da4292b15d3a27b5ea1555f11452a470815..475a99b2a3b1800c9d3e3e5f77a64f552fa35828 100644
174--- a/ios/Shared/MenuViewImplementation.swift
175+++ b/ios/Shared/MenuViewImplementation.swift
176@@ -60,17 +60,46 @@ public class MenuViewImplementation: UIButton {
177 }
179 public override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
180- sendMenuOpen()
181+ // Flush updates deferred by the presented-guard before the action
182+ // provider snapshots self.menu (covers a stuck flag from an
183+ // interaction that never ended cleanly).
184+ if pendingMenu != nil {
185+ pendingMenu = nil
186+ isMenuPresented = false
187+ self.setup()
188+ }
189+ isMenuPresented = true
190+ sendMenuInteractionStart()
191 return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
192 guard let self = self else { return nil }
193 return self.menu
194 }
195 }
196-
198+ public override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willDisplayMenuFor configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) {
199+ // UIKit can request a configuration for a press that never opens a
200+ // menu. Notify React only once presentation actually begins, and
201+ // preserve UIButton's presentation behavior by calling super.
202+ super.contextMenuInteraction(interaction, willDisplayMenuFor: configuration, animator: animator)
203+ sendMenuOpen()
204+ }
206 public override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willEndFor configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) {
207+ super.contextMenuInteraction(interaction, willEndFor: configuration, animator: animator)
208 sendMenuClose()
209+ isMenuPresented = false
210+ if pendingMenu != nil {
211+ // Re-run the full assignment now that presentation is over, so
212+ // any props deferred by the presented-guard (menu contents, press
213+ // mode) land on the button.
214+ pendingMenu = nil
215+ self.setup()
216+ }
217 }
219+ private var isMenuPresented = false
220+ private var pendingMenu: UIMenu?
222 func setup () {
223 let menu = UIMenu(title: _title,
224 identifier: nil,
225@@ -86,8 +115,102 @@ public class MenuViewImplementation: UIButton {
226 }
227 }
229+ if isMenuPresented {
230+ // An action fired with keepsMenuPresented leaves the menu on
231+ // screen, and reassigning self.menu while it is presented makes
232+ // UIKit dismiss it — the update triggered by a selection would
233+ // defeat the keep-presented attribute. Update the visible copy in
234+ // place instead and defer the button assignment to dismissal.
235+ pendingMenu = menu
236+ self.refreshPresentedMenu(menu)
237+ return
238+ }
240 self.menu = menu
241 self.showsMenuAsPrimaryAction = !shouldOpenOnLongPress
242+ // In long-press mode the button must not intercept touches: as a
243+ // full-bounds contentView it sits IN FRONT of the React children of
244+ // the hosting component view, which would swallow their taps (e.g. a
245+ // row Pressable wrapped by MenuView). The context-menu interaction is
246+ // hosted by the superview instead (see updateLongPressInteraction) so
247+ // long-press and pointer secondary-click still present the menu, with
248+ // the wrapped content as the zoom preview.
249+ self.isUserInteractionEnabled = !shouldOpenOnLongPress
250+ self.updateLongPressInteraction()
251+ }
253+ private func refreshPresentedMenu(_ menu: UIMenu) {
254+ // Tap mode presents through the button's built-in interaction,
255+ // long-press mode through the superview-hosted one; cover both (plus
256+ // the interaction added in init) and dedupe by identity.
257+ var candidates = self.interactions.compactMap { $0 as? UIContextMenuInteraction }
258+ if let builtin = self.contextMenuInteraction {
259+ candidates.append(builtin)
260+ }
261+ if let host = longPressInteraction {
262+ candidates.append(host)
263+ }
264+ var visited: Set<ObjectIdentifier> = []
265+ for interaction in candidates where visited.insert(ObjectIdentifier(interaction)).inserted {
266+ // The block receives whichever menu level is currently on screen —
267+ // the navigated submenu when the user picked inside one, not the
268+ // root. Swap in the matching node from the rebuilt tree (stable
269+ // identifiers from the JS action ids) so that level updates in
270+ // place; returning an unrelated menu instead makes UIKit render it
271+ // as navigation into a foreign menu, with a stale or blank
272+ // expanded-submenu header row above the actions. The root carries
273+ // an auto-generated identifier that never matches, so it falls
274+ // through to a children-only replacement.
275+ interaction.updateVisibleMenu { [weak self] visibleMenu in
276+ guard let self = self else { return visibleMenu }
277+ if let replacement = self.menuMatching(visibleMenu.identifier, in: menu) {
278+ return replacement
279+ }
280+ return visibleMenu.replacingChildren(menu.children)
281+ }
282+ }
283+ }
285+ private func menuMatching(_ identifier: UIMenu.Identifier, in menu: UIMenu) -> UIMenu? {
286+ if menu.identifier == identifier {
287+ return menu
288+ }
289+ for element in menu.children {
290+ if let submenu = element as? UIMenu, let match = menuMatching(identifier, in: submenu) {
291+ return match
292+ }
293+ }
294+ return nil
295+ }
297+ private var longPressInteraction: UIContextMenuInteraction?
299+ public override func didMoveToSuperview() {
300+ super.didMoveToSuperview()
301+ self.updateLongPressInteraction()
302+ }
304+ private func updateLongPressInteraction() {
305+ if shouldOpenOnLongPress, let host = self.superview {
306+ if let existing = longPressInteraction, existing.view === host {
307+ return
308+ }
309+ if let existing = longPressInteraction {
310+ existing.view?.removeInteraction(existing)
311+ }
312+ // UIControl's built-in interaction presents a compact menu that
313+ // preserves the keyboard; a separate view interaction presents a
314+ // rich context menu and temporarily hides it.
315+ guard let interaction = self.contextMenuInteraction else { return }
316+ host.addInteraction(interaction)
317+ longPressInteraction = interaction
318+ return
319+ }
320+ if let existing = longPressInteraction {
321+ existing.view?.removeInteraction(existing)
322+ self.addInteraction(existing)
323+ longPressInteraction = nil
324+ }
325 }
327 public override func reactSetFrame(_ frame: CGRect) {
328@@ -124,4 +247,8 @@ public class MenuViewImplementation: UIButton {
329 @objc func sendMenuOpen() {
330 // NO-OP (should be overriden by parent)
331 }
333+ @objc func sendMenuInteractionStart() {
334+ // NO-OP (should be overriden by parent)
335+ }
336 }
337diff --git a/ios/Shared/RCTMenuItem.swift b/ios/Shared/RCTMenuItem.swift
338index bb6bb2b7ad56135089f267587c974b166760539d..949b3f7ec49af7ba26d966a8923a51f619443d5a 100644
339--- a/ios/Shared/RCTMenuItem.swift
340+++ b/ios/Shared/RCTMenuItem.swift
341@@ -103,10 +103,18 @@ class RCTMenuAction {
342 subMenuActions.append(subaction.createUIMenuElement(handler))
343 }
344 var menu: UIMenu;
345+ // Stable identifiers let updateVisibleMenu match submenu nodes in
346+ // place, so a refresh while the menu is presented keeps the user's
347+ // current submenu level instead of popping back to the root.
348+ // Inline sections don't navigate, so they stay stock.
349+ let menuIdentifier = identifier.map { UIMenu.Identifier(rawValue: $0.rawValue) }
350 if self.displayInline {
351 menu = UIMenu(title: title, image: image, options: .displayInline, children: subMenuActions)
352 } else {
353- menu = UIMenu(title: title, image: image, children: subMenuActions)
354+ menu = UIMenu(title: title, image: image, identifier: menuIdentifier, children: subMenuActions)
355+ }
356+ if #available(iOS 15.0, *) {
357+ menu.subtitle = subtitle
358 }
360 if #available(iOS 16.0, *) {
361diff --git a/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts b/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts
362index e6509355275596c451f9d082223cc16bfe504e1a..dd16e1a7403970cc3a404355f95ed99580776353 100644
363--- a/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts
364+++ b/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts
365@@ -48,6 +48,7 @@ export interface NativeProps extends ViewProps {
366 onPressAction?: DirectEventHandler<{ event: string }>;
367 onCloseMenu?: DirectEventHandler<{ event: string }>;
368 onOpenMenu?: DirectEventHandler<{ event: string }>;
369+ onMenuInteractionStart?: DirectEventHandler<{ event: string }>;
370 actions: Array<MenuAction>;
371 actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
372 title?: string;
373diff --git a/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts b/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts
374index e6509355275596c451f9d082223cc16bfe504e1a..dd16e1a7403970cc3a404355f95ed99580776353 100644
375--- a/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts
376+++ b/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts
377@@ -48,6 +48,7 @@ export interface NativeProps extends ViewProps {
378 onPressAction?: DirectEventHandler<{ event: string }>;
379 onCloseMenu?: DirectEventHandler<{ event: string }>;
380 onOpenMenu?: DirectEventHandler<{ event: string }>;
381+ onMenuInteractionStart?: DirectEventHandler<{ event: string }>;
382 actions: Array<MenuAction>;
383 actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
384 title?: string;
385diff --git a/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts b/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
386index 24ee7fdcd9f81cfe2c813cfca9d4e276b846fb7b..c1b4ea53b29193283295d35c18e068f2836c6176 100644
387--- a/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
388+++ b/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
389@@ -41,6 +41,9 @@ export interface NativeProps extends ViewProps {
390 onOpenMenu?: DirectEventHandler<{
391 event: string;
392 }>;
393+ onMenuInteractionStart?: DirectEventHandler<{
394+ event: string;
395+ }>;
396 actions: Array<MenuAction>;
397 actionsHash: string;
398 title?: string;
399diff --git a/lib/typescript/src/index.d.ts b/lib/typescript/src/index.d.ts
400index 61d210aa9364f0354f77bddaecdc0a127b1cdbb4..0672bea3352b9ad0623124e308f740c70a7e6940 100644
401--- a/lib/typescript/src/index.d.ts
402+++ b/lib/typescript/src/index.d.ts
403@@ -4,6 +4,7 @@ declare const MenuView: import("react").ForwardRefExoticComponent<{
404 onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
405 onCloseMenu?: () => void;
406 onOpenMenu?: () => void;
407+ onMenuInteractionStart?: () => void;
408 actions: MenuAction[];
409 title?: string;
410 isAnchoredToRight?: boolean;
411diff --git a/lib/typescript/src/types.d.ts b/lib/typescript/src/types.d.ts
412index eac7940ab7eb6a69ac329848c9f3eeffdcbaf43d..19e82df15b042bc0cda27349b2b8a8ee1d3f0b51 100644
413--- a/lib/typescript/src/types.d.ts
414+++ b/lib/typescript/src/types.d.ts
415@@ -113,6 +113,12 @@ type MenuComponentPropsBase = {
416 * Callback function that will be called when the menu opens.
417 */
418 onOpenMenu?: () => void;
419+ /**
420+ * Callback function that will be called when UIKit starts preparing a menu interaction.
421+ * Preparation can end without the menu opening.
422+ * @platform iOS
423+ */
424+ onMenuInteractionStart?: () => void;
425 /**
426 * Actions to be displayed in the menu.
427 */
428@@ -170,6 +176,7 @@ export type NativeMenuComponentProps = {
429 onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
430 onCloseMenu?: () => void;
431 onOpenMenu?: () => void;
432+ onMenuInteractionStart?: () => void;
433 actions: ProcessedMenuAction[];
434 actionsHash: string;
435 title?: string;
436diff --git a/src/NativeModuleSpecs/UIMenuNativeComponent.ts b/src/NativeModuleSpecs/UIMenuNativeComponent.ts
437index e6509355275596c451f9d082223cc16bfe504e1a..604dba0d90a2545910f8724a80205565de2391d4 100644
438--- a/src/NativeModuleSpecs/UIMenuNativeComponent.ts
439+++ b/src/NativeModuleSpecs/UIMenuNativeComponent.ts
440@@ -13,6 +13,22 @@ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNati
441 types here, to avoid issues while `pod install` takes place.
442 */
444+type SubSubAction = {
445+ id?: string;
446+ title: string;
447+ titleColor?: Int32;
448+ subtitle?: string;
449+ state?: string;
450+ image?: string;
451+ imageColor?: Int32;
452+ displayInline?: boolean;
453+ attributes?: {
454+ destructive?: boolean;
455+ disabled?: boolean;
456+ hidden?: boolean;
457+ keepsMenuPresented?: boolean;
458+ };
459+};
460 type SubAction = {
461 id?: string;
462 title: string;
463@@ -26,7 +42,11 @@ type SubAction = {
464 destructive?: boolean;
465 disabled?: boolean;
466 hidden?: boolean;
467+ keepsMenuPresented?: boolean;
468 };
469+ // One extra nesting level (menu → submenu → nested submenu leaves); the
470+ // codegen structs can't recurse, so depth is capped explicitly.
471+ subactions?: Array<SubSubAction>;
472 };
473 type MenuAction = {
474 id?: string;
475@@ -41,6 +61,7 @@ type MenuAction = {
476 destructive?: boolean;
477 disabled?: boolean;
478 hidden?: boolean;
479+ keepsMenuPresented?: boolean;
480 };
481 subactions?: Array<SubAction>;
482 };
483@@ -48,6 +69,7 @@ export interface NativeProps extends ViewProps {
484 onPressAction?: DirectEventHandler<{ event: string }>;
485 onCloseMenu?: DirectEventHandler<{ event: string }>;
486 onOpenMenu?: DirectEventHandler<{ event: string }>;
487+ onMenuInteractionStart?: DirectEventHandler<{ event: string }>;
488 actions: Array<MenuAction>;
489 actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
490 title?: string;
491diff --git a/src/types.ts b/src/types.ts
492index 9c323d9c510e7359c83d4d6633affde673570632..5d5fdfb8b8235fcaa8295b85630443eaf5991a17 100644
493--- a/src/types.ts
494+++ b/src/types.ts
495@@ -123,6 +123,12 @@ type MenuComponentPropsBase = {
496 * Callback function that will be called when the menu opens.
497 */
498 onOpenMenu?: () => void;
499+ /**
500+ * Callback function that will be called when UIKit starts preparing a menu interaction.
501+ * Preparation can end without the menu opening.
502+ * @platform iOS
503+ */
504+ onMenuInteractionStart?: () => void;
505 /**
506 * Actions to be displayed in the menu.
507 */
508@@ -189,6 +195,7 @@ export type NativeMenuComponentProps = {
509 onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
510 onCloseMenu?: () => void;
511 onOpenMenu?: () => void;
512+ onMenuInteractionStart?: () => void;
513 actions: ProcessedMenuAction[];
514 actionsHash: string;
515 title?: string;