Skip to content

[web] Selection highlighting should be disabled via keyboard shortcuts when enableInteractiveSelection: false for TextFields #117165

@htoor3

Description

@htoor3

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Click into TextField and enter some text
  3. Use shift + left or shift + right to highlight text.

Expected results: Text selection/highlighting is possible.

Actual results: The cursor should just move left/right without highlighting.

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: const Center(
        child: TextField(
          enableInteractiveSelection: false, // selection disabled
          onChanged: print,
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel master, 3.7.0-9.0.pre.18, on macOS 12.6.1 21G217 darwin-arm64, locale en-US)
    • Flutter version 3.7.0-9.0.pre.18 on channel master at /Users/hassantoor/Desktop/flutter
    • Upstream repository git@github.com:flutter/flutter.git
    • Framework revision b122200d4c (2 hours ago), 2022-12-15 13:56:06 -0500
    • Engine revision 29196519c1
    • Dart version 3.0.0 (build 3.0.0-21.0.dev)
    • DevTools version 2.20.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/hassantoor/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Users/hassantoor/Desktop/../Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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.12+0-b1504.28-7817840)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.6.1 21G217 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.98

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

• No issues found!

Web:

flutter.issue.mov

MacOS (doesn't highlight selection on keyboard shortcuts):

flutter.issue.macos.mov

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.platform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions