Skip to content

TextField scrolling jumps around when dragging text selection handle upwards #132047

Closed

Description

@joshminton

Is there an existing issue for this?

Steps to reproduce

  1. Run code
  2. Long press a word near the bottom of the text field to select it (and then end the long-press)
  3. Tap the selection handle at the start of the highlighted word, and drag it upwards

Expected results

The text field should scroll smoothly (as it does if you do not end the long-press at the end of step 2. but simply drag finger upwards immediately)

Actual results

The scrolling jumps around -- see video here

scroll-bug.mov

('Screenshots or video' section isn't showing up for some reason)

Code sample

Code sample
import 'dart:io';

import 'package:flutter/cupertino.dart';
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> {
  final TextEditingController _textEditingController = TextEditingController(
      text:
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque sodales ut etiam sit amet nisl. Molestie nunc non blandit massa enim nec dui. Ornare quam viverra orci sagittis eu volutpat odio. In vitae turpis massa sed elementum tempus. Laoreet non curabitur gravida arcu ac tortor dignissim. In cursus turpis massa tincidunt dui ut ornare lectus sit. Enim praesent elementum facilisis leo vel fringilla est. Volutpat diam ut venenatis tellus in. Ut sem viverra aliquet eget sit amet. Dictum at tempor commodo ullamcorper a. Aliquam nulla facilisi cras fermentum odio eu feugiat. Tristique et egestas quis ipsum suspendisse ultrices. Elementum sagittis vitae et leo duis ut. Aliquet risus feugiat in ante. Pretium fusce id velit ut tortor pretium viverra. Dictumst quisque sagittis purus sit amet volutpat consequat mauris nunc. Turpis tincidunt id aliquet risus feugiat in ante metus dictum. Viverra aliquet eget sit amet tellus cras adipiscing. Nisl tincidunt eget nullam non nisi est sit.\nVelit aliquet sagittis id consectetur. Elementum curabitur vitae nunc sed velit. Ante in nibh mauris cursus mattis molestie. Vel elit scelerisque mauris pellentesque. Commodo sed egestas egestas fringilla phasellus faucibus. Rutrum tellus pellentesque eu tincidunt tortor. Nec ullamcorper sit amet risus nullam eget felis eget nunc. At urna condimentum mattis pellentesque. Mi sit amet mauris commodo quis imperdiet. Iaculis eu non diam phasellus vestibulum lorem. Tempus iaculis urna id volutpat lacus laoreet non curabitur. Venenatis lectus magna fringilla urna porttitor rhoncus dolor purus non. At tempor commodo ullamcorper a. Nisl vel pretium lectus quam id leo in vitae. Mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque. Ultrices eros in cursus turpis massa. Et tortor consequat id porta nibh venenatis cras sed felis. Amet luctus venenatis lectus magna fringilla urna porttitor. Est sit amet facilisis magna etiam. Lacus vestibulum sed arcu non odio euismod lacinia.\nAmet consectetur adipiscing elit pellentesque habitant morbi tristique senectus. Commodo nulla facilisi nullam vehicula ipsum a arcu cursus. Pretium lectus quam id leo in vitae turpis massa. Proin nibh nisl condimentum id. Dui nunc mattis enim ut tellus elementum. Libero enim sed faucibus turpis in eu mi bibendum. Eu tincidunt tortor aliquam nulla facilisi cras fermentum odio eu. Porttitor eget dolor morbi non. Nulla facilisi cras fermentum odio eu feugiat pretium nibh ipsum. Cum sociis natoque penatibus et magnis. Metus dictum at tempor commodo ullamcorper a. Convallis tellus id interdum velit laoreet id. Mi in nulla posuere sollicitudin aliquam ultrices sagittis orci.\nLacinia quis vel eros donec ac odio tempor orci. Risus nec feugiat in fermentum. Convallis convallis tellus id interdum. Eget velit aliquet sagittis id consectetur purus ut faucibus. Fringilla est ullamcorper eget nulla. Commodo ullamcorper a lacus vestibulum sed arcu non. Nulla aliquet enim tortor at. Malesuada proin libero nunc consequat interdum varius sit amet. Faucibus ornare suspendisse sed nisi lacus. Pharetra et ultrices neque ornare aenean euismod. Et malesuada fames ac turpis egestas maecenas pharetra convallis. Urna molestie at elementum eu facilisis. Morbi tristique senectus et netus et malesuada fames ac. Diam quis enim lobortis scelerisque fermentum dui faucibus in. Luctus accumsan tortor posuere ac ut consequat semper viverra nam. Justo laoreet sit amet cursus sit. Morbi blandit cursus risus at ultrices. Sem fringilla ut morbi tincidunt augue interdum velit. Ultricies leo integer malesuada nunc vel risus commodo viverra. Orci sagittis eu volutpat odio facilisis mauris.\nElit sed vulputate mi sit amet mauris. Risus nullam eget felis eget nunc lobortis mattis aliquam. Consectetur a erat nam at lectus urna. Tincidunt dui ut ornare lectus sit amet est. Neque aliquam vestibulum morbi blandit. Maecenas sed enim ut sem viverra aliquet eget. In massa tempor nec feugiat nisl pretium. Donec adipiscing tristique risus nec feugiat in fermentum posuere. Elit at imperdiet dui accumsan sit amet nulla facilisi morbi. Feugiat vivamus at augue eget. Quam id leo in vitae turpis. Nibh tellus molestie nunc non. Ipsum dolor sit amet consectetur adipiscing. Sit amet consectetur adipiscing elit ut aliquam purus sit.");

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: TextField(
        controller: _textEditingController,
        selectionControls: Platform.isIOS ? CupertinoTextSelectionControls() : MaterialTextSelectionControls(),
        autofocus: true,
        textCapitalization: TextCapitalization.sentences,
        maxLines: null,
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
scroll-bug.mov

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.13.0-17.0.pre.77, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
    • Flutter version 3.13.0-17.0.pre.77 on channel master at /opt/homebrew/Caskroom/flutter/3.0.0/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7de053b2b8 (4 hours ago), 2023-08-07 03:51:33 -0400
    • Engine revision eb91441398
    • Dart version 3.2.0 (build 3.2.0-41.0.dev)
    • DevTools version 2.26.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/joshminton/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio 2.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio 2.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 11.0.15+0-b2043.56-8887301)

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • 2B171FDH2008K5 • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos          • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 115.0.5790.114

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Activity

  1. darshankawar commented on Aug 8, 2023

    @darshankawar
    Member

    Thanks for the report. I was able to replicate the reported behavior. Maybe related to #89024 ?

    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.10.6, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.10.6 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision f468f3366c (5 days ago), 2023-07-12 15:19:05 -0700
        • Engine revision cdbeda788a
        • Dart version 3.0.6
        • DevTools version 2.23.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • 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 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.13.0-19.0.pre.77, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.13.0-19.0.pre.77 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 08b2c44413 (2 hours ago), 2023-08-07 22:59:25 -0400
        • Engine revision 9c83d90b01
        • Dart version 3.2.0 (build 3.2.0-42.0.dev)
        • DevTools version 2.26.1
        • 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 30.0.3)
        • Android SDK at /Users/dhs/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 13C100
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 65.1.4
        • Dart plugin version 213.7228
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.29.0
    
    [✓] Connected device (3 available)
        • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
          • iOS 15.3.1 19D52
        • macOS (desktop)           • macos                                    •
          darwin-x64     • macOS 12.2.1 21D62 darwin-x64
        • Chrome (web)              • chrome                                   •
          web-javascript • Google Chrome 109.0.5414.119
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
          
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • 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 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  2. added
    f: scrollingViewports, list views, slivers, etc.
    f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIs
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    a: text inputEntering text in a text field or keyboard related problems
    and removed
    in triagePresently being triaged by the triage team
    on Aug 8, 2023
  3. joshminton commented on Aug 8, 2023

    @joshminton
    Author

    Thanks @darshankawar . It might be worth mentioning that on the stable branch, I don't have the issue. However, on stable I do have a different issue with TextFields, which I reported in #131936 not realising it was already fixed in master. My own workaround for that issue was to wrap the TextField in a SingleChildScrollView, but that resulted in the same behaviour as I've reported here in this issue. So, it appears to me that whatever changes have been made in master fixed the behaviour I referenced in #131936 but may have resulted in this issue.

  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Aug 10, 2023
  5. 13 remaining items

  6. loic-sharma commented on Apr 30, 2026

    @loic-sharma
    Member

    Reopening as @Alspb and @saurabh-mirajkar were able to reproduce this issue on 3.41.

  7. moved this from Incoming Issues to In progress in SelectableRegion Improvementson May 1, 2026
  8. unlocked this conversation on May 5, 2026
  9. moved this from In progress to No status in SelectableRegion Improvementson May 5, 2026
  10. 1123434219a-lab commented on Jun 3, 2026

    @1123434219a-lab

    I can consistently reproduce this severe jittering issue on Android with a very minimal setup.

    The Root Cause (Viewport Anchor Mismatch)

    Through deep debugging, I found the root cause isn't just edge auto-scrolling, but a viewport tracking anchor mismatch inside RenderEditable / EditableText:

    1. When dragging the Start Handle (Left Cursor) upwards, the text engine mistakenly tries to invoke showCaretOnScreen() to keep the Extent Handle (Right Cursor) in view.
    2. This creates a violent, frame-by-frame tug-of-war: the user gesture pulls the viewport to the top (Start Handle), while the layout pipeline forces the viewport to the bottom (Extent Handle).
    3. Upon releasing the gesture, the viewport immediately falls back to the bottom, displaying only the right cursor/end of selection.

    Minimal Reproducible Code

    import 'package:flutter/material.dart';
    
    void main() => runApp(MaterialApp(home: TestApp()));
    
    class TestApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: TextField(
              minLines: 1,
              maxLines: 5,
            ),
          ),
        );
      }
    }

    Steps to Reproduce

    1. Type a long multi-line text into the TextField until it triggers vertical scrolling (exceeds 5 lines).

    2. Select all text.

    3. Hold and drag the start selection handle (top-left) upwards.

    4. Result: The whole text area and selection handles start stuttering and shaking violently. When released, the viewport snaps directly to the end of the text selection.

  11. added a commit that references this issue on Sep 25, 2026
    c4ed827
  12. github-actions commented on Oct 9, 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.

  13. locked as resolved and limited conversation to collaborators on Oct 9, 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: 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13found in release: 3.41Found to occur in 3.41frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: solvedIssue is closed as solvedteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions