Skip to content

Shift tap on an unfocused field #97534

@justinmc

Description

@justinmc

Currently, shift+tap on an unfocused field continues the selection that was last in that field. This seems to be correct for all platforms except for Mac, which always starts the selection at 0. We should get this behavior correct on Mac too.

CC @dkwingsmt, who noticed this in #95213 (comment).

To reproduce

  1. Run the app below on Mac (or just use any text field).
  2. Type something in the input.
  3. Unfocus the field by clicking elsewhere.
  4. Hold shift and tap in the middle of the field.

Expected behavior: The selection goes from 0 to the click location.
Actual behavior: The selection goes from the previous cursor location (end of the field) to the click location.

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(),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.platform-macBuilding on or for macOS specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions