Skip to content

Commit 6801fc3

Browse files
Saadnajmifacebook-github-bot
authored andcommitted
Remove an early return to suppress a deprecated API warning for UIMenuController (#42277)
Summary: `UIMenuController` is deprecated as of iOS 16. e08a197 migrated a usage into an `available` check. However, it does not properly fall back to the deprecated API in the "else" block of the availability check, instead it uses an early return. It seems this means Xcode still sees the API as used, and spits out a deprecated warning. Let's just refactor the code so we don't have that anymore. ## Changelog: [IOS] [FIXED] - Remove an early return to suppress a deprecated API warning for `UIMenuController` Pull Request resolved: #42277 Test Plan: CI should pass. Reviewed By: cipolleschi Differential Revision: D52785488 Pulled By: sammy-SC fbshipit-source-id: 0b47e8aa8d7c94728e3d68332fbb8f97f8ded34e
1 parent 17824fd commit 6801fc3

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)