Skip to content

Cursor should collapse after a paste #98677

Closed

Description

@justinmc

When pasting onto a non-collapsed selection, the selection should collapse. Confirmed on native Mac, Windows, Android and iOS. I'd be shocked if Linux isn't the same too.

If you paste with the keyboard while the cursor is offscreen, the cursor should be scrolled into view, but it isn't.

Steps to reproduce

  1. Run any app with a text field, such as the one below.
  2. Enter some text, like "asdf".
  3. Copy any text.
  4. Make any selection of length > 0.
  5. Paste (using the keyboard or using the toolbar).

Expected: The cursor ends up collapsed at the end of the pasted text.
Actual: The pasted text is selected.

Code
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: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Demo'),
        ),
        body: const Center(
          child: TextField(),
        ),
      ),
    );
  }
}

Related: #98604 (comment)

Activity

  1. self-assigned this
    on Feb 17, 2022
  2. maheshj01 commented on Feb 18, 2022

    @maheshj01
    Member

    Hi @justinmc, I am able to reproduce this issue on Linux and mac on both stable and the master channel. The pasted text remains selected and the cursor doesn't show up as it should compared to native platforms.

    output

    MacOS

    MacOS Desktop Linux Desktop
    Screen.Recording.2022-02-18.at.3.13.10.PM.mov
    linux.mp4

    IOS

    Screen.Recording.2022-02-18.at.3.08.42.PM.mov

    Android

    Pasting via keyboard Pasting via toolbar
    Screen.Recording.2022-02-18.at.2.08.37.PM.mov
    Screen.Recording.2022-02-18.at.2.10.48.PM.mov
    flutter doctor -v (macos)
    [✓] Flutter (Channel stable, 2.10.1, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.10.1 at /Users/mahesh/Documents/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision db747aa133 (8 days ago), 2022-02-09 13:57:35 -0600
        • Engine revision ab46186b24
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.34.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)    • chrome • web-javascript • Google Chrome 98.0.4758.102
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.11.0-0.0.pre.582, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.11.0-0.0.pre.582 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9514106108 (2 days ago), 2022-02-16 00:00:11 -0500
        • Engine revision b09cf53269
        • Dart version 2.17.0 (build 2.17.0-105.0.dev)
        • DevTools version 2.10.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.34.0
    
    [✓] Connected device (3 available)
        • Redmi K20 Pro (mobile) • 192.168.1.2:5555 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome           • web-javascript • Google Chrome 98.0.4758.102
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    flutter doctor -v (Linux)
    [✓] Flutter (Channel stable, 2.10.1, on Ubuntu 20.04.3 LTS 5.13.0-28-generic, locale en_GB.UTF-8)
        • Flutter version 2.10.1 at /home/mahesh/Development/stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision db747aa133 (9 days ago), 2022-02-09 13:57:35 -0600
        • Engine revision ab46186b24
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /home/mahesh/Android/Sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at google-chrome
    
    [✓] Linux toolchain - develop for Linux desktop
        • clang version 10.0.0-4ubuntu1
        • cmake version 3.16.3
        • ninja version 1.10.0
        • pkg-config version 0.29.1
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
        • Flutter plugin version 63.2.1
        • Dart plugin version 203.8452
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /usr/share/code
        • Flutter extension version 3.34.0
    
    [✓] Connected device (2 available)
        • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.3 LTS 5.13.0-28-generic
        • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.11.0-0.0.pre.613, on Ubuntu 20.04.3 LTS 5.13.0-28-generic, locale en_GB.UTF-8)
        • Flutter version 2.11.0-0.0.pre.613 at /home/mahesh/Development/master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 02a182dd96 (68 minutes ago), 2022-02-18 02:24:27 -0500
        • Engine revision 0fd7713f2b
        • Dart version 2.17.0 (build 2.17.0-119.0.dev)
        • DevTools version 2.11.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /home/mahesh/Android/Sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at google-chrome
    
    [✓] Linux toolchain - develop for Linux desktop
        • clang version 10.0.0-4ubuntu1
        • cmake version 3.16.3
        • ninja version 1.10.0
        • pkg-config version 0.29.1
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
        • Flutter plugin version 63.2.1
        • Dart plugin version 203.8452
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /usr/share/code
        • Flutter extension version 3.34.0
    
    [✓] Connected device (2 available)
        • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.3 LTS 5.13.0-28-generic
        • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  3. added
    a: fidelityMatching the OEM platforms better
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    p: material_uimaterial_ui package in flutter/packages
    and removed
    in triagePresently being triaged by the triage team
    on Feb 18, 2022
  4. added
    r: fixedIssue is closed as already fixed in a newer version
    on Feb 25, 2022
  5. github-actions commented on Mar 11, 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.

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

Metadata

Metadata

Assignees

Labels

a: fidelityMatching the OEM platforms bettera: text inputEntering text in a text field or keyboard related problemsfound in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11frameworkflutter/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: 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