Skip to content

Commit

Permalink
[iOS] Remove an early return to suppress a deprecated API warning for…
Browse files Browse the repository at this point in the history
… `UIMenuController`
  • Loading branch information
Saadnajmi committed Jan 16, 2024
1 parent 51fd418 commit 10aa706
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
16 changes: 6 additions & 10 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,15 @@ - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
if (_editMenuInteraction) {
[_editMenuInteraction presentEditMenuWithConfiguration:config];
}
return;
}
UIMenuController *menuController = [UIMenuController sharedMenuController];
} else {
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (menuController.isMenuVisible) {
return;
}
if (menuController.isMenuVisible) {
return;
}

if (!self.isFirstResponder) {
[self becomeFirstResponder];
[menuController showMenuFromView:self rect:self.bounds];
}

[menuController showMenuFromView:self rect:self.bounds];
}

- (BOOL)canBecomeFirstResponder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,25 +236,21 @@ - (void)disableContextMenu

- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
if (@available(iOS 16.0, *)) {
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
CGPoint location = [gesture locationInView:self];
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
if (_editMenuInteraction) {
[_editMenuInteraction presentEditMenuWithConfiguration:config];
}
return;
}
UIMenuController *menuController = [UIMenuController sharedMenuController];
} else {
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (menuController.isMenuVisible) {
return;
}
if (menuController.isMenuVisible) {
return;
}

if (!self.isFirstResponder) {
[self becomeFirstResponder];
[menuController showMenuFromView:self rect:self.bounds];
}

[menuController showMenuFromView:self rect:self.bounds];
}

- (BOOL)canBecomeFirstResponder
Expand Down

0 comments on commit 10aa706

Please sign in to comment.