Skip to content

Commit 79b2ccf

Browse files
fix(mobile): preserve keyboard in native long-press menus
1 parent 052b8b0 commit 79b2ccf

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎patches/@[email protected]‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ index 6a2a205f95c1001f3fdf6fb835815fa7c4c02c16..4f42b64349966fb1438f72439cec8256
170170
+
171171
}
172172
diff --git a/ios/Shared/MenuViewImplementation.swift b/ios/Shared/MenuViewImplementation.swift
173-
index 5c4e0da4292b15d3a27b5ea1555f11452a470815..4d8abe3c4fc45bda48c2958bc9ca933c77f2cc47 100644
173+
index 5c4e0da4292b15d3a27b5ea1555f11452a470815..475a99b2a3b1800c9d3e3e5f77a64f552fa35828 100644
174174
--- a/ios/Shared/MenuViewImplementation.swift
175175
+++ b/ios/Shared/MenuViewImplementation.swift
176176
@@ -60,17 +60,46 @@ public class MenuViewImplementation: UIButton {
@@ -222,7 +222,7 @@ index 5c4e0da4292b15d3a27b5ea1555f11452a470815..4d8abe3c4fc45bda48c2958bc9ca933c
222222
func setup () {
223223
let menu = UIMenu(title: _title,
224224
identifier: nil,
225-
@@ -86,8 +115,98 @@ public class MenuViewImplementation: UIButton {
225+
@@ -86,8 +115,102 @@ public class MenuViewImplementation: UIButton {
226226
}
227227
}
228228

@@ -309,19 +309,23 @@ index 5c4e0da4292b15d3a27b5ea1555f11452a470815..4d8abe3c4fc45bda48c2958bc9ca933c
309309
+ if let existing = longPressInteraction {
310310
+ existing.view?.removeInteraction(existing)
311311
+ }
312-
+ let interaction = UIContextMenuInteraction(delegate: self)
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 }
313316
+ host.addInteraction(interaction)
314317
+ longPressInteraction = interaction
315318
+ return
316319
+ }
317320
+ if let existing = longPressInteraction {
318321
+ existing.view?.removeInteraction(existing)
322+
+ self.addInteraction(existing)
319323
+ longPressInteraction = nil
320324
+ }
321325
}
322326

323327
public override func reactSetFrame(_ frame: CGRect) {
324-
@@ -124,4 +243,8 @@ public class MenuViewImplementation: UIButton {
328+
@@ -124,4 +247,8 @@ public class MenuViewImplementation: UIButton {
325329
@objc func sendMenuOpen() {
326330
// NO-OP (should be overriden by parent)
327331
}
@@ -379,7 +383,7 @@ index e6509355275596c451f9d082223cc16bfe504e1a..dd16e1a7403970cc3a404355f95ed995
379383
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)
380384
title?: string;
381385
diff --git a/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts b/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
382-
index 24ee7fdcd9f81cfe2c813cfca9d4e276b846fb7b..5ee7b45bafea8547d68949aaba70584055f9fb53 100644
386+
index 24ee7fdcd9f81cfe2c813cfca9d4e276b846fb7b..c1b4ea53b29193283295d35c18e068f2836c6176 100644
383387
--- a/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
384388
+++ b/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts
385389
@@ -41,6 +41,9 @@ export interface NativeProps extends ViewProps {
@@ -393,7 +397,7 @@ index 24ee7fdcd9f81cfe2c813cfca9d4e276b846fb7b..5ee7b45bafea8547d68949aaba705840
393397
actionsHash: string;
394398
title?: string;
395399
diff --git a/lib/typescript/src/index.d.ts b/lib/typescript/src/index.d.ts
396-
index 61d210aa9364f0354f77bddaecdc0a127b1cdbb4..84ac2bc8b4edac045ed59896d5eb4e6eaef4725d 100644
400+
index 61d210aa9364f0354f77bddaecdc0a127b1cdbb4..0672bea3352b9ad0623124e308f740c70a7e6940 100644
397401
--- a/lib/typescript/src/index.d.ts
398402
+++ b/lib/typescript/src/index.d.ts
399403
@@ -4,6 +4,7 @@ declare const MenuView: import("react").ForwardRefExoticComponent<{
@@ -405,7 +409,7 @@ index 61d210aa9364f0354f77bddaecdc0a127b1cdbb4..84ac2bc8b4edac045ed59896d5eb4e6e
405409
title?: string;
406410
isAnchoredToRight?: boolean;
407411
diff --git a/lib/typescript/src/types.d.ts b/lib/typescript/src/types.d.ts
408-
index eac7940ab7eb6a69ac329848c9f3eeffdcbaf43d..271cd27f777be06bc02f05d4b4dac5bb940f5f0f 100644
412+
index eac7940ab7eb6a69ac329848c9f3eeffdcbaf43d..19e82df15b042bc0cda27349b2b8a8ee1d3f0b51 100644
409413
--- a/lib/typescript/src/types.d.ts
410414
+++ b/lib/typescript/src/types.d.ts
411415
@@ -113,6 +113,12 @@ type MenuComponentPropsBase = {

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)