Skip to content

[iOS] Selection handles sometimes disappear while quickly dragging in TextField/CupertinoTextField #168636

@b3nni97

Description

@b3nni97

Steps to reproduce

  1. Create a minimal Flutter app containing a single TextField/CupertinoTextField(see code below).

  2. Type a few words, then double-tap to place the caret and bring up the selection handles.

  3. Quickly drag either selection handle left ↔ right several times.

Expected results

Selection handles should remain visible and track the user’s finger, even during very fast drags—matching native iOS behaviour.

Actual results

While dragging at high speed, the selection handles (and the system-style context menu) vanish unexpectedly.
Text selection is lost until the user lifts their finger and double taps again.


I don´t know if it helps but, the disappearance originates in ServicesBinding._handlePlatformMessage:

// Called when the system dismisses the system context menu, such as when
// the user taps outside the menu…
case 'ContextMenu.onDismissSystemContextMenu':
  if (_systemContextMenuClient == null) {
    assert(false,
      'Platform sent onDismissSystemContextMenu when no SystemContextMenuClient was registered.');
    return;
  }
  _systemContextMenuClient!.handleSystemHide();
  _systemContextMenuClient = null;
  break;

According to the comment, this callback should fire only when the user taps outside the menu.
However, a fast drag gesture appears to be interpreted as such a tap, triggering handleSystemHide() and clearing _systemContextMenuClient, which in turn hides both the context menu and the selection handles.

Code sample

Code sample
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
     return const CupertinoApp(
      home: CupertinoPageScaffold(
        navigationBar: CupertinoNavigationBar(
          middle: Text('TextField Selection Issue'),
        ),
        child: Center(
          child: Padding(
            padding: EdgeInsets.symmetric(horizontal: 24),
            child: CupertinoTextField(),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Flutter App:

ScreenRecording_05-11-2025.03-08-30_1.MP4

Native iOS App:

ScreenRecording_05-11-2025.03-09-22_1.MP4

Logs

No response

Flutter Doctor output

Doctor output
Flutter 3.32.0-0.3.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 3bd718ee44 (10 days ago) • 2025-04-30 10:11:08 -0700
Engine • revision 453dd7174c (11 days ago) • 2025-04-29 21:15:41 -0700
Tools • Dart 3.8.0 (build 3.8.0-278.2.beta) • DevTools 2.45.1

Metadata

Metadata

Labels

a: text inputEntering text in a text field or keyboard related problemsf: cupertinoflutter/packages/flutter/cupertino repositoryf: material designflutter/packages/flutter/material repository.found in release: 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions