Skip to content

Text selection leads to scrolling in opposite direction #89024

Closed

Description

@DhivakarK-git

Steps to Reproduce

Minimal example

class TestTextSelectionScroll extends StatefulWidget {
  @override
  _TestTextSelectionScrollState createState() =>
      _TestTextSelectionScrollState();
}

class _TestTextSelectionScrollState extends State<TestTextSelectionScroll> {
  final TextEditingController _body = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: ListView(
          children: [
            TextField(
              controller: _body,
              style: Theme.of(context).textTheme.bodyText1,
              maxLines: null,
            ),
          ],
        ),
      ),
    );
  }
}

issue01

Any Textfield, Textformfield in listview has unwanted scrolling in the opposite direction of scroll when selecting long lines of text within the field.

Expected results: Scroll only when cursor moves out of the viewport(not sure if thats the term)

Actual results: Unusual Scrolling in the opposite direction

Details [√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1165], locale en-IN) • Flutter version 2.2.3 at C:\Android\flutter • Framework revision f4abaa0 (8 weeks ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Android\sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = C:\Android
• ANDROID_SDK_ROOT = C:\Android\sdk
• Java binary at: C:\Android\openjdk\bin\java
• Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.8.4)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.8.30907.101
• Windows 10 SDK version 10.0.19041.0

[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.59.1)
• VS Code at ########
• Flutter extension version 3.25.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1165]
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.78

Activity

  1. darshankawar commented on Aug 27, 2021

    @darshankawar
    Member

    @DhivakarK-git
    Can you check if it occurs on physical device too ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 27, 2021
  3. DhivakarK-git commented on Aug 27, 2021

    @DhivakarK-git
    Author

    @DhivakarK-git
    Can you check if it occurs on physical device too ?

    Yes, I wasn't able to share a video of the same, but I first noticed it on a physical device and then tried it with the minimal example above.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 27, 2021
  5. 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 27, 2021
  6. HansMuller commented on Aug 27, 2021

    @HansMuller
    Contributor
  7. darshankawar commented on Aug 30, 2021

    @darshankawar
    Member

    @DhivakarK-git
    Tried the same on Pixel 5 emulator on latest master but couldn't replicate the issue. Can you try the same on latest master and confrim ?

  8. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 30, 2021
  9. DhivakarK-git commented on Aug 30, 2021

    @DhivakarK-git
    Author

    @darshankawar
    Problem still persists in the latest master and latest android sdk. It happens when the no. of text lines in length is atleast twice that of the length of viewport. Happens when u try to drag the handles up or down.

    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: TestTextSelectionScroll(),
        );
      }
    }
    
    class TestTextSelectionScroll extends StatefulWidget {
      @override
      _TestTextSelectionScrollState createState() =>
          _TestTextSelectionScrollState();
    }
    
    class _TestTextSelectionScrollState extends State<TestTextSelectionScroll> {
      final TextEditingController _body = TextEditingController();
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Container(
            child: ListView(
              children: [
                TextField(
                  controller: _body,
                  maxLines: null,
                ),
              ],
            ),
          ),
        );
      }
    }
    
    Details [√] Flutter (Channel master, 2.6.0-1.0.pre.112, on Microsoft Windows [Version 10.0.19043.1165], locale en-IN) • Flutter version 2.6.0-1.0.pre.112 at C:\Android\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 0c65de1 (7 hours ago), 2021-08-30 05:26:01 -0400 • Engine revision c05688f • Dart version 2.15.0 (build 2.15.0-65.0.dev)

    [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = C:\Android
    • ANDROID_SDK_ROOT = C:\Android\sdk
    • Java binary at: C:\Android\openjdk\bin\java
    • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
    • All Android licenses accepted.

    [√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

    [√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.8.4)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.8.30907.101
    • Windows 10 SDK version 10.0.19041.0

    [!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
    (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

    [√] VS Code (version 1.59.1)
    • VS Code at ########
    • Flutter extension version 3.25.0

    [√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1165]
    • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
    • Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.84

  10. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 30, 2021
  11. darshankawar commented on Aug 31, 2021

    @darshankawar
    Member

    Thanks for the updates. Verified again on latest master and stable and observed the same behavior.

    stable, master flutter doctor -v
    [✓] Flutter (Channel stable, 2.2.3, on Mac OS X 10.15.4 19E2269 darwin-x64,
        locale en-GB)
        • Flutter version 2.2.3 at /Users/dhs/documents/fluttersdk/flutter
        • Framework revision f4abaa0735 (4 days ago), 2021-07-01 12:46:11 -0700
        • Engine revision 241c87ad80
        • Dart version 2.13.4
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30)
        • Android SDK at /Users/dhs/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/dhs/Library/Android/sdk
        • Java binary at: /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.    
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.3, Build version 12C33
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • Android Studio at /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/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
          1.8.0_242-release-1644-b3-6915495)        
    
    [✓] VS Code (version 1.57.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (4 available)
        • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29)
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                               •
          web-javascript • Google Chrome 91.0.4472.114
    
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.6.0-1.0.pre.134, on Mac OS X 10.15.4 19E2269
        darwin-x64, locale en-GB)
        • Flutter version 2.6.0-1.0.pre.134 at
          /Users/dhs/documents/fluttersdk/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 6902a04c22 (3 hours ago), 2021-08-30 23:01:05 -0400
        • Engine revision 6c11ffe9ba
        • Dart version 2.15.0 (build 2.15.0-66.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30)
        • Android SDK at /Users/dhs/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/dhs/Library/Android/sdk
        • Java binary at: /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.    
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • Android Studio at /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/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
          1.8.0_242-release-1644-b3-6915495)        
    
    [✓] VS Code (version 1.57.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (4 available)
        • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29)
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                               •
          web-javascript • Google Chrome 91.0.4472.114
    
    
    
    
  12. 2 remaining items

  13. added
    f: scrollingViewports, list views, slivers, etc.
    and removed
    in triagePresently being triaged by the triage team
    on Aug 31, 2021
  14. changed the title [-]TextField,TextformField TextSelection causes scrolling when inside ListView,SingleChildScrollView[/-] [+]Text selection leads to scrolling in opposite direction[/+] on Aug 31, 2021
  15. DhivakarK-git commented on Sep 2, 2021

    @DhivakarK-git
    Author

    Thanks for the updates. Verified again on latest master and stable and observed the same behavior.

    stable, master flutter doctor -v

    @darshankawar
    any possible workaround for now?

  16. added
    f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIs
    P2Important issues not at the top of the work list
    on Mar 17, 2023
  17. Renzo-Olivares commented on Jun 2, 2026

    @Renzo-Olivares
    Contributor

    Closing this issue as a duplicate of #132047. Please feel free to re-open if this is not the case.

  18. github-actions commented on Jul 14, 2026

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

  19. locked as resolved and limited conversation to collaborators on Jul 14, 2026
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

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: scrollingViewports, list views, slivers, etc.f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsfound in release: 2.2Found to occur in 2.2found in release: 2.6Found to occur in 2.6frameworkflutter/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/packagesr: duplicateIssue is closed as a duplicate of an existing issueteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions