Skip to content

[macOS] Navigating between suggestions on accent panel produces unhandled key sound #134699

@angelosilvestre

Description

@angelosilvestre

Is there an existing issue for this?

Steps to reproduce

  1. Run the sample code on mac
  2. Press and hold "a" until the accent panel is displayed
  3. Press right/left arrow to navigate between the suggestions

Expected results

The navigation happens on the suggestions and the OS does not emit any sound on every key press

Actual results

Navigation happens on the suggestions followed by the OS sound that indicates that the key event was not handled.

This also happens with the TextField.

Code sample

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

void main() {
  runApp(
    const MaterialApp(
      home: Scaffold(
        body: TextInputExample(),
      ),
    ),
  );
}

class TextInputExample extends StatefulWidget {
  const TextInputExample({Key? key}) : super(key: key);

  @override
  State<TextInputExample> createState() => _TextInputExampleState();
}

class _TextInputExampleState extends State<TextInputExample> implements DeltaTextInputClient {
  TextInputConnection? _inputConnection;

  TextEditingValue _currentEditingValue = TextEditingValue(
    text: '',
    selection: TextSelection.collapsed(offset: 0),
  );

  FocusNode _focusNode = FocusNode();

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      _attach();
    });
  }

  @override
  void dispose() {
    _focusNode.dispose();
    super.dispose();
  }

  @override
  void updateEditingValueWithDeltas(List<TextEditingDelta> textEditingDeltas) {
    TextEditingValue newEditingValue = _currentEditingValue;

    for (final delta in textEditingDeltas) {
      newEditingValue = delta.apply(newEditingValue);
    }

    setState(() {
      _currentEditingValue = newEditingValue;
    });
  }

  void _attach() {
    if (_inputConnection != null) {
      return;
    }
    _inputConnection = TextInput.attach(
      this,
      const TextInputConfiguration(
        enableDeltaModel: true,
        inputType: TextInputType.multiline,
        textCapitalization: TextCapitalization.sentences,
        inputAction: TextInputAction.newline,
        keyboardAppearance: Brightness.light,
      ),
    );

    final renderBox = context.findRenderObject() as RenderBox;

    _inputConnection!
      ..show()
      ..setEditingState(_currentEditingValue)
      ..setEditableSizeAndTransform(renderBox.size, renderBox.getTransformTo(null))
      ..setCaretRect(
        Rect.fromCenter(center: renderBox.size.center(Offset.zero), width: 50, height: 50),
      );
  }

  @override
  Widget build(BuildContext context) {
    return Actions(
      actions: {
        // Prevent Flutter from using the arrow keys to perform focus traversal.
        DoNothingAndStopPropagationTextIntent: DoNothingAction(consumesKey: false),
      },
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              'Press and hold "a"',
              style: TextStyle(fontSize: 18),
            ),
            Focus(
              focusNode: _focusNode,
              autofocus: true,
              child: Text(
                _currentEditingValue.text,
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void connectionClosed() {}

  @override
  AutofillScope? get currentAutofillScope => null;

  @override
  TextEditingValue? get currentTextEditingValue => null;

  @override
  void insertTextPlaceholder(Size size) {}

  @override
  void performAction(TextInputAction action) {}

  @override
  void performPrivateCommand(String action, Map<String, dynamic> data) {}

  @override
  void removeTextPlaceholder() {}

  @override
  void showAutocorrectionPromptRect(int start, int end) {}

  @override
  void showToolbar() {}

  @override
  void updateEditingValue(TextEditingValue value) {}

  @override
  void updateFloatingCursor(RawFloatingCursorPoint point) {}

  @override
  void didChangeInputControl(TextInputControl? oldControl, TextInputControl? newControl) {}

  @override
  void insertContent(KeyboardInsertedContent content) {}

  @override
  void performSelector(String selectorName) {}
}

Screenshots or Video

No response

Logs

Logs
No relevant logs

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.14.0-14.0.pre.282, on macOS 13.5.1 22G90
    darwin-arm64, locale pt-BR)
    • Flutter version 3.14.0-14.0.pre.282 on channel master at
      /Users/angelosilvestre/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5243d18e8d (2 hours ago), 2023-09-13 16:33:16 -0400
    • Engine revision 154d6fd601
    • Dart version 3.2.0 (build 3.2.0-140.0.dev)
    • DevTools version 2.27.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/angelosilvestre/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2022.3)
    • 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
      17.0.6+0-17.0.6b829.9-10027231)

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

[✓] Connected device (3 available)
    • iPhone 14 Pro (mobile) • AD5DBB2E-DE25-40C9-9346-CE61E9971B76 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)        • macos                                •
      darwin-arm64   • macOS 13.5.1 22G90 darwin-arm64
    • Chrome (web)           • chrome                               •
      web-javascript • Google Chrome 117.0.5938.62

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions