react / react/react-native

iOS: selectable Text edit menu flickers on long-press release (handleLongPress ignores gesture.state)

オープン 初心者向け
#58,079 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Author Feedback Needs: Repro Stale
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

On iOS 16+ (New Architecture), long-pressing a <Text selectable> shows the edit menu ("Copy"), and the moment the finger is lifted the menu animates out and immediately back in. It is a ~100 ms blink on every release, on every selectable Text.

Cause: RCTParagraphComponentView.handleLongPress: does not check gesture.state. A UILongPressGestureRecognizer fires its action on Began and again on Ended (and on Changed when the finger moves). The second call re-runs [_editMenuInteraction presentEditMenuWithConfiguration:], and UIKit dismisses the presented menu before presenting the new one.

https://github.com/react/react-native/blob/v0.87.0/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm#L346-L353

- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
  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];
    }
  } else {
    // the legacy branch is guarded by `menuController.isMenuVisible`; the iOS 16 branch is not

Fix (verified, see below):

- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
  if (gesture.state != UIGestureRecognizerStateBegan) {
    return;
  }
  ...

Happy to open a PR if that helps.

Steps to reproduce
  1. Render <Text selectable>Some text</Text> in any screen (New Architecture, iOS 16+).
  2. Long-press the text until "Copy" appears.
  3. Lift the finger.

Expected: the menu stays. Actual: the menu disappears and reappears at touch-up.

Evidence: screen recording of the simulator at 20 fps, OCR of each frame for "Copy" (C = menu visible, . = not):

before: ....CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC..CCCCCCCCCCCCCCCCCCCCCCC....
after:  ....CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC....

The gap in the first line is the release (Maestro longPressOn, ~3 s hold). The second line is the same scenario with the one-line guard compiled in (built from source, ios.buildReactNativeFromSource in Expo).

React Native Version

0.86.2 (code unchanged in 0.87.0)

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System: macOS 26.2
Xcode: 26.4
iOS Simulator: iPhone 17 Pro
react-native: 0.86.2 (Expo SDK 57), New Architecture, Hermes
Stacktrace or Logs
n/a (visual)
MANDATORY Reproducer

Any <Text selectable> on iOS 16+ with the New Architecture reproduces it; the bug is fully explained by the source above (the action handler is invoked for every gesture state).

Screenshots and Videos

Frame-by-frame OCR trace above.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm を開き、handleLongPress: を調査してください。New Architecture を使用した iOS 16+ で選択可能な Text の長押しを再現し、その後、指を離しても編集メニューがちらつかず表示されたままであることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ios, objective-c, react-native
領域
mobile
issue の種類
バグ
難易度
1/5
見積もり時間
1時間未満
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
88/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。