Skip to content

Longpressing on an unselected word in a text field should select it (iOS) #64190

Description

@justinmc

Steps to Reproduce

  1. Run an app with a text field on an iOS device (e.g. the code below).
  2. Enter some text in the field.
  3. Long press on a word that is not currently selected.
  4. The cursor is moved to that position in Flutter, but on native iOS, the word is selected.

On native, longpressing on the collapsed cursor allows it to be dragged around. We should make sure that behavior is preserved when this is fixed.

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Demo',
      home: Scaffold(
        appBar: AppBar(title: Text('Demo')),
        body: Center(
          child: TextField(),
        ),
      ),
    );
  }
}

Activity

  1. justinmc commented on Aug 19, 2020

    @justinmc
    ContributorAuthor

    There is some code deduplication that can probably happen when this is fixed. See https://github.com/flutter/flutter/pull/63994/files#r473348460.

  2. added
    a: text inputEntering text in a text field or keyboard related problems
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 20, 2020
  3. darshankawar commented on Aug 27, 2020

    @darshankawar
    Member

    Issue replicable on latest stable (1.20.2). Tested on iphone 6s and observed that tapping longpress on an entered text shows paste, select all toolbar, but doesn't select the word.

    IMG-0198

    flutter doctor -v
    Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision bbfbf1770c (15 hours ago) • 2020-08-13 08:33:09 -0700
    Engine • revision 9d5b21729f
    Tools • Dart 2.9.1
    
    Running flutter doctor...
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.2 19C57, locale en-US)
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        ✗ Android license status unknown.
          Try re-installing or updating your Android SDK Manager.
          See https://developer.android.com/studio/#downloads or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
    [✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    [✓] Android Studio (version 3.6)
    [✓] Connected device (1 available)
    
    ! Doctor found issues in 1 category.
    
  4. Renzo-Olivares commented on Sep 23, 2022

    @Renzo-Olivares
    Contributor

    cc @justinmc can this be closed? The behavior on iOS 16 is long pressing moves the cursor to the pressed position, which matches the current flutter behavior.

    Edit:
    Behavior seems to be if a TextField is focused then long pressing moves the cursor to the pressed position.
    If the TextField is not focused then long pressing selects the word at the pressed position.

  5. justinmc commented on Sep 26, 2022

    @justinmc
    ContributorAuthor

    @Renzo-Olivares Is your edit referring to native iOS 16 behavior? How did you reproduce that behavior? I tried in Messages and it still just placed the cursor even when the field wasn't focused, but I realized I was using iOS 15. Trying to upgrade now.

    Otherwise if that's not something that we need to implement in Flutter then I agree this should be closed. I confirmed that the behavior in the issue description doesn't happen on native iOS anymore.

  6. Renzo-Olivares commented on Sep 27, 2022

    @Renzo-Olivares
    Contributor

    @justinmc I tried this on iOS 16 on the notes app. I am however not seeing the same behavior in the Messages app, it only places the cursor at the long press position. Maybe that behavior is custom to the notes app then?

  7. justinmc commented on Sep 27, 2022

    @justinmc
    ContributorAuthor

    The Files app also seems to place the cursor. I say let's close this!

  8. added
    r: fixedIssue is closed as already fixed in a newer version
    on Sep 28, 2022
  9. github-actions commented on Oct 12, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsf: gesturesflutter/packages/flutter/gestures repository.found in release: 1.20Found to occur in 1.20frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions