Skip to content

Commit c597c62

Browse files
committed
[iOS] Remove an early return to suppress a deprecated API warning for UIMenuController
1 parent f30acc6 commit c597c62

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,27 +241,26 @@ - (void)disableContextMenu
241241
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
242242
{
243243
#if !TARGET_OS_UIKITFORMAC
244-
if (@available(iOS 16.0, *)) {
244+
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
245245
CGPoint location = [gesture locationInView:self];
246246
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
247247
if (_editMenuInteraction) {
248248
[_editMenuInteraction presentEditMenuWithConfiguration:config];
249249
}
250-
return;
251-
}
252-
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
253-
UIMenuController *menuController = [UIMenuController sharedMenuController];
254-
255-
if (menuController.isMenuVisible) {
256-
return;
257-
}
250+
} else {
251+
UIMenuController *menuController = [UIMenuController sharedMenuController];
258252

259-
if (!self.isFirstResponder) {
260-
[self becomeFirstResponder];
261-
}
253+
if (menuController.isMenuVisible) {
254+
return;
255+
}
262256

257+
if (!self.isFirstResponder) {
258+
[self becomeFirstResponder];
259+
}
260+
263261
[menuController setTargetRect:self.bounds inView:self];
264262
[menuController setMenuVisible:YES animated:YES];
263+
}
265264
#endif
266265
}
267266

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,27 +237,26 @@ - (void)disableContextMenu
237237
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
238238
{
239239
#if !TARGET_OS_UIKITFORMAC
240-
if (@available(iOS 16.0, *)) {
240+
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
241241
CGPoint location = [gesture locationInView:self];
242242
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
243243
if (_editMenuInteraction) {
244244
[_editMenuInteraction presentEditMenuWithConfiguration:config];
245245
}
246-
return;
247-
}
248-
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
249-
UIMenuController *menuController = [UIMenuController sharedMenuController];
250-
251-
if (menuController.isMenuVisible) {
252-
return;
253-
}
246+
} else {
247+
UIMenuController *menuController = [UIMenuController sharedMenuController];
254248

255-
if (!self.isFirstResponder) {
256-
[self becomeFirstResponder];
257-
}
249+
if (menuController.isMenuVisible) {
250+
return;
251+
}
258252

253+
if (!self.isFirstResponder) {
254+
[self becomeFirstResponder];
255+
}
256+
259257
[menuController setTargetRect:self.bounds inView:self];
260258
[menuController setMenuVisible:YES animated:YES];
259+
}
261260
#endif
262261
}
263262

0 commit comments

Comments
 (0)