Skip to content

Invalid TextField scroll offset change on paste from toolbar #96658

@tgucio

Description

@tgucio

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Copy the text from the first line and paste it at the end of the second line using toolbar

Expected results: TextField doesn't scroll as caret is already visible

Actual results: TextField scrolls

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'bringIntoView test'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('Copy & paste stuff below:'),
            Expanded(
              child: TextField(
                focusNode: FocusNode(),
                controller: TextEditingController(
                  text: 'Copy this whoooooollleeeeee line\nPaste it here using toolbar: \n' + ('.\n' * 50),
                ),
                maxLines: null,
                style: const TextStyle(fontSize: 36.0, color: Colors.black),
                cursorColor: Colors.grey,
              ),
            )
          ],
        ),
      ),
    );
  }
}
Logs
 % flutter doctor -v
[✓] Flutter (Channel master, 2.9.0-1.0.pre.363, on macOS 12.1 21C52 darwin-x64, locale en-GB)
    • Flutter version 2.9.0-1.0.pre.363 at /Library/Frameworks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9e9a728667 (11 hours ago), 2022-01-14 09:40:11 +0800
    • Engine revision f121c1fe68
    • Dart version 2.17.0 (build 2.17.0-11.0.dev)
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/jsmith/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2020.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.10+0-b96-7281165)

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.32.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.1 21C52 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.71

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.found in release: 2.10Found to occur in 2.10found in release: 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions