Skip to content

Mac cmd + shift + arrow expand behavior #93883

@justinmc

Description

@justinmc

On Mac, cmd + shift + arrow left/right should expand the selection to the beginning/end of the current line, not pivot it. Here's a recording of Flutter's current incorrect behavior and then the correct native TextEdit:

Screen.Recording.2021-11-18.at.10.54.37.AM.mov

This used to work before. @LongCatIsLooong I believe your PR #90684 accidentally removed this behavior. Sorry I should have caught it in code review or at least had a test to catch it.

Steps to reproduce

  1. Run any app with any sort of text field with some text in it (example app below).
  2. Click to place the cursor somewhere in the middle of a line.
  3. Press cmd + shift + left arrow to select to the start of the line.
  4. Press cmd + shift + right arrow to select to the end of the line.

Expected behavior: The selection expands to include the entire line.
Actual behavior: The selection pivots to only include the original click point to the end of the line.

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

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

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

  final TextEditingController _controller = TextEditingController(
    text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Padding(
          padding: const EdgeInsets.all(32.0),
          child: Column(
            children: <Widget>[
              TextField(
                controller: _controller,
                maxLines: 3,
                decoration: InputDecoration(
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(0.5),
                    gapPadding: 0.0,
                  ),
                  labelText: 'I am a label',
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowfound in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-macBuilding on or for macOS specificallyr: 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