diff --git a/bin/internal/flutter_plugins.version b/bin/internal/flutter_plugins.version index 155f82286010b..81b7d715accfc 100644 --- a/bin/internal/flutter_plugins.version +++ b/bin/internal/flutter_plugins.version @@ -1 +1 @@ -d9fc677ab06fa4cc0913e21d0c09e309f5dad18e +6d88e3a2a1848ed93670890bc79532426b1344a2 diff --git a/packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart b/packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart index 71ccd914a9dfe..9e28520ab9edd 100644 --- a/packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart +++ b/packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart @@ -207,6 +207,10 @@ class DefaultTextEditingShortcuts extends Shortcuts { const SingleActivator(LogicalKeyboardKey.keyA, control: true): const SelectAllTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyZ, control: true): const UndoTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyZ, shift: true, control: true): const RedoTextIntent(SelectionChangedCause.keyboard), + // These keys should go to the IME when a field is focused, not to other + // Shortcuts. + const SingleActivator(LogicalKeyboardKey.space): const DoNothingAndStopPropagationTextIntent(), + const SingleActivator(LogicalKeyboardKey.enter): const DoNothingAndStopPropagationTextIntent(), }; // The following key combinations have no effect on text editing on this @@ -328,6 +332,10 @@ class DefaultTextEditingShortcuts extends Shortcuts { const SingleActivator(LogicalKeyboardKey.keyA, meta: true): const SelectAllTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyZ, meta: true): const UndoTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyZ, shift: true, meta: true): const RedoTextIntent(SelectionChangedCause.keyboard), + // These keys should go to the IME when a field is focused, not to other + // Shortcuts. + const SingleActivator(LogicalKeyboardKey.space): const DoNothingAndStopPropagationTextIntent(), + const SingleActivator(LogicalKeyboardKey.enter): const DoNothingAndStopPropagationTextIntent(), // The following key combinations have no effect on text editing on this // platform: // * End @@ -410,6 +418,7 @@ class DefaultTextEditingShortcuts extends Shortcuts { const SingleActivator(LogicalKeyboardKey.end, control: true): const DoNothingAndStopPropagationTextIntent(), const SingleActivator(LogicalKeyboardKey.home, control: true): const DoNothingAndStopPropagationTextIntent(), const SingleActivator(LogicalKeyboardKey.space): const DoNothingAndStopPropagationTextIntent(), + const SingleActivator(LogicalKeyboardKey.enter): const DoNothingAndStopPropagationTextIntent(), const SingleActivator(LogicalKeyboardKey.keyX, control: true): const DoNothingAndStopPropagationTextIntent(), const SingleActivator(LogicalKeyboardKey.keyX, meta: true): const DoNothingAndStopPropagationTextIntent(), const SingleActivator(LogicalKeyboardKey.keyC, control: true): const DoNothingAndStopPropagationTextIntent(), diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index 8ba96c63fe793..7f44228b20704 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -11474,6 +11474,48 @@ void main() { ); }, variant: TargetPlatformVariant.all(), skip: kIsWeb); // [intended] }); + + // Regression test for https://github.com/flutter/flutter/issues/98322. + testWidgets('EditableText consumes ActivateIntent and ButtonActivateIntent', (WidgetTester tester) async { + bool receivedIntent = false; + await tester.pumpWidget( + MaterialApp( + home: Actions( + actions: >{ + ActivateIntent: CallbackAction(onInvoke: (_) { + receivedIntent = true; + return; + }), + ButtonActivateIntent: CallbackAction(onInvoke: (_) { + receivedIntent = true; + return; + }), + }, + child: EditableText( + autofocus: true, + backgroundCursorColor: Colors.blue, + controller: controller, + focusNode: focusNode, + style: textStyle, + cursorColor: cursorColor, + ), + ), + ), + ); + + await tester.pump(); + expect(focusNode.hasFocus, isTrue); + + // ActivateIntent, which is triggered by space and enter in WidgetsApp, is + // consumed by EditableText so that the space/enter reach the IME. + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + expect(receivedIntent, isFalse); + + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.pump(); + expect(receivedIntent, isFalse); + }); } class UnsettableController extends TextEditingController {