Skip to content

Commit 10aa706

Browse files
committed
[iOS] Remove an early return to suppress a deprecated API warning for UIMenuController
1 parent 51fd418 commit 10aa706

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

packages/react-native/Libraries/Text/Text/RCTTextView.mm

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,15 @@ - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
246246
if (_editMenuInteraction) {
247247
[_editMenuInteraction presentEditMenuWithConfiguration:config];
248248
}
249-
return;
250-
}
251-
UIMenuController *menuController = [UIMenuController sharedMenuController];
249+
} else {
250+
UIMenuController *menuController = [UIMenuController sharedMenuController];
252251

253-
if (menuController.isMenuVisible) {
254-
return;
255-
}
252+
if (menuController.isMenuVisible) {
253+
return;
254+
}
256255

257-
if (!self.isFirstResponder) {
258-
[self becomeFirstResponder];
256+
[menuController showMenuFromView:self rect:self.bounds];
259257
}
260-
261-
[menuController showMenuFromView:self rect:self.bounds];
262258
}
263259

264260
- (BOOL)canBecomeFirstResponder

packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,21 @@ - (void)disableContextMenu
236236

237237
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
238238
{
239-
if (@available(iOS 16.0, *)) {
239+
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
240240
CGPoint location = [gesture locationInView:self];
241241
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
242242
if (_editMenuInteraction) {
243243
[_editMenuInteraction presentEditMenuWithConfiguration:config];
244244
}
245-
return;
246-
}
247-
UIMenuController *menuController = [UIMenuController sharedMenuController];
245+
} else {
246+
UIMenuController *menuController = [UIMenuController sharedMenuController];
248247

249-
if (menuController.isMenuVisible) {
250-
return;
251-
}
248+
if (menuController.isMenuVisible) {
249+
return;
250+
}
252251

253-
if (!self.isFirstResponder) {
254-
[self becomeFirstResponder];
252+
[menuController showMenuFromView:self rect:self.bounds];
255253
}
256-
257-
[menuController showMenuFromView:self rect:self.bounds];
258254
}
259255

260256
- (BOOL)canBecomeFirstResponder

0 commit comments

Comments
 (0)