Skip to content

TextField that embedded in the GestureDetector can't be selected #129161

Closed

Description

@LucasXu0

Is there an existing issue for this?

Steps to reproduce

  1. create a textfield and wrap it into the gesture detector.

Expected results

the textfield can be selected and updated.

Actual results

can't select the text

Code sample

Code sample
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            GestureDetector(
              onTap: () {
                print('single tap');
              },
              onDoubleTap: () {
                print('double tap');
              },
              // this textfield can't be selected
              child: TextField(
                controller: TextEditingController()..text = 'Initial Text',
              ),
            ),
            // this textfield can be selected
            TextField(
              controller: TextEditingController()..text = 'Initial Text',
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel unknown, 3.10.1, on macOS 13.0 22A5358e darwin-arm64, locale en-CN)
    ! Flutter version 3.10.1 on channel unknown at /Users/lucas.xu/Desktop/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.79.2)
[✓] Connected device (3 available)
[✓] Network resources

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Jun 20, 2023
  2. huycozy commented on Jun 20, 2023

    @huycozy
    Member

    Thanks for filing this issue. Checking this across Flutter versions, it appears on the latest stable and master channels but works as expected on Flutter 3.7.12.

    Per your Flutter version and the latest working version, this may be introduced in 3.10.0 or 3.10.1.

    Demo
    stable/master ❌ 3.7.12 ✅
    Screen.Recording.2023-06-20.at.19.14.48.mov
    Screen.Recording.2023-06-20.at.19.18.08.mov
    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.10.5, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.10.5 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 796c8ef792 (29 hours ago), 2023-06-13 15:51:02 -0700
        • Engine revision 45f6e00911
        • Dart version 3.0.5
        • DevTools version 2.23.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.79.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (5 available)
        • Pixel 3a (mobile)      • 964AY0WL20                               • android-arm64  • Android 12 (API 32)
        • iPhone (mobile)        • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios            • iOS 15.7.2 19H218
        • iPhone 14 Pro (mobile) • 98082851-A0C4-4E39-A310-21C48B10A364     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
        • macOS (desktop)        • macos                                    • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)           • chrome                                   • web-javascript • Google Chrome 114.0.5735.133
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel master, 3.12.0-4.0.pre.121, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.12.0-4.0.pre.121 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not
          inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding
          /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside
          your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding
          /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5182697c0d (2 hours ago), 2023-06-19 21:37:33 -0400
        • Engine revision a91bb3f566
        • Dart version 3.1.0 (build 3.1.0-230.0.dev)
        • DevTools version 2.24.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
          to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.79.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.133
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  3. added
    a: text inputEntering text in a text field or keyboard related problems
    c: regressionIt was better in the past than it is now
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    f: gesturesflutter/packages/flutter/gestures repository.
    and removed
    in triagePresently being triaged by the triage team
    on Jun 20, 2023
  4. TahaTesser commented on Jun 20, 2023

    @TahaTesser
    Contributor

    This might be a change in behavior. I'll take a closer look tomorrow.

  5. mikhael28 commented on Jun 20, 2023

    @mikhael28

    There is a first time for everything - this was the first time that I've been negatively affected by a new Flutter release. Once every year and a half, I will take those odds :) But yes, apparently wrapping TextFields in a gesture detector will make the form fields innaccessible (unless you long press a field/force touch on a mac trackpad).

    Either way, I'm going to have to push out a hotfix for this - I wish I found out about this sooner. Please comment to let us know when this is addressed.

  6. goderbauer commented on Jun 20, 2023

    @goderbauer
    Member
  7. added
    P2Important issues not at the top of the work list
    on Jun 20, 2023
  8. bleroux commented on Jun 21, 2023

    @bleroux
    Contributor

    I bisected this to #117502 which was a great improvement.

  9. Renzo-Olivares commented on Jun 21, 2023

    @Renzo-Olivares
    Contributor

    @bleroux Thanks for looking into that! I think I know what is happening. We use currentDown from the _TapStatusTrackerMixin when we fire the tap down event in the recognizer. The _TapStatusTrackerMixin consecutive tap timer is timing out while the GestureArena is delaying victory because we have TapGestureRecognizer, DoubleTapGestureRecognizer, and TapAndDragGestureRecognizer and all of them wait for all recognizers to declare a loss. Even though at the end of this interaction TapAndDragGestureRecognizer is declared victorious, currentDown has become null and no tap down event is fired as a result, so the TextField cannot be selected. I'll put a PR out to correct this. The solution may be not to depend on currentDown when firing a tap down event.

  10. added a commit that references this issue on Jun 23, 2023
    3c366b7
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 23, 2023
  12. mikhael28 commented on Jun 23, 2023

    @mikhael28

    @Renzo-Olivares I'm assuming this will be released in the next weekly hotfix?

  13. github-actions commented on Jul 7, 2023

    @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.

  14. locked as resolved and limited conversation to collaborators on Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: gesturesflutter/packages/flutter/gestures repository.found in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: 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