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 15, 2024
1 parent f30acc6 commit c597c62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
23 changes: 11 additions & 12 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,26 @@ - (void)disableContextMenu
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
#if !TARGET_OS_UIKITFORMAC
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;
}
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (menuController.isMenuVisible) {
return;
}
} else {
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (!self.isFirstResponder) {
[self becomeFirstResponder];
}
if (menuController.isMenuVisible) {
return;
}

if (!self.isFirstResponder) {
[self becomeFirstResponder];
}

[menuController setTargetRect:self.bounds inView:self];
[menuController setMenuVisible:YES animated:YES];
}
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,27 +237,26 @@ - (void)disableContextMenu
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
#if !TARGET_OS_UIKITFORMAC
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;
}
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (menuController.isMenuVisible) {
return;
}
} else {
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (!self.isFirstResponder) {
[self becomeFirstResponder];
}
if (menuController.isMenuVisible) {
return;
}

if (!self.isFirstResponder) {
[self becomeFirstResponder];
}

[menuController setTargetRect:self.bounds inView:self];
[menuController setMenuVisible:YES animated:YES];
}
#endif
}

Expand Down

0 comments on commit c597c62

Please sign in to comment.