Skip to content

Cursor should collapse after a paste #98677

@justinmc

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)

Metadata

Metadata

Assignees

Labels

a: fidelityMatching the OEM platforms bettera: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found 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 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