Skip to content

Commit abecef6

Browse files
authored
Revert "Fix ActivateIntent overriding the spacebar for text entry (flutter#91129)" (flutter#92544)
This reverts commit a24d556.
1 parent b025e38 commit abecef6

File tree

3 files changed

+1
-90
lines changed

3 files changed

+1
-90
lines changed

packages/flutter/lib/src/widgets/app.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,10 +1149,6 @@ class WidgetsApp extends StatefulWidget {
11491149
/// with "s".
11501150
static bool debugAllowBannerOverride = true;
11511151

1152-
// Any shortcuts added here have the potential to conflict with normal text
1153-
// input. If this should not happen and text input should take preference,
1154-
// then add a shortcut for the relevant key in DefaultTextEditingShortcuts
1155-
// mapped to DoNothingAndStopPropagationTextIntent.
11561152
static const Map<ShortcutActivator, Intent> _defaultShortcuts = <ShortcutActivator, Intent>{
11571153
// Activation
11581154
SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),
@@ -1210,11 +1206,6 @@ class WidgetsApp extends StatefulWidget {
12101206
};
12111207

12121208
// Default shortcuts for the macOS platform.
1213-
//
1214-
// Any shortcuts added here have the potential to conflict with normal text
1215-
// input. If this should not happen and text input should take preference,
1216-
// then add a shortcut for the relevant key in DefaultTextEditingShortcuts
1217-
// mapped to DoNothingAndStopPropagationTextIntent.
12181209
static const Map<ShortcutActivator, Intent> _defaultAppleOsShortcuts = <ShortcutActivator, Intent>{
12191210
// Activation
12201211
SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),

packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ class DefaultTextEditingShortcuts extends Shortcuts {
160160
child: child,
161161
);
162162

163-
static const Map<ShortcutActivator, Intent> _commonShortcuts = <ShortcutActivator, Intent>{
164-
// Allows space and enter to be used as input instead of a shortcut by
165-
// another widget. See https://github.com/flutter/flutter/issues/90907
166-
SingleActivator(LogicalKeyboardKey.space): DoNothingAndStopPropagationTextIntent(),
167-
SingleActivator(LogicalKeyboardKey.enter): DoNothingAndStopPropagationTextIntent(),
168-
};
169-
170163
static const Map<ShortcutActivator, Intent> _androidShortcuts = <ShortcutActivator, Intent>{
171164
SingleActivator(LogicalKeyboardKey.backspace): DeleteTextIntent(),
172165
SingleActivator(LogicalKeyboardKey.backspace, control: true): DeleteByWordTextIntent(),
@@ -539,7 +532,7 @@ class DefaultTextEditingShortcuts extends Shortcuts {
539532
SingleActivator(LogicalKeyboardKey.keyA, meta: true): DoNothingAndStopPropagationTextIntent(),
540533
};
541534

542-
static Map<ShortcutActivator, Intent> get _platformShortcuts {
535+
static Map<ShortcutActivator, Intent> get _shortcuts {
543536
if (kIsWeb) {
544537
return _webShortcuts;
545538
}
@@ -559,11 +552,4 @@ class DefaultTextEditingShortcuts extends Shortcuts {
559552
return _windowsShortcuts;
560553
}
561554
}
562-
563-
static Map<ShortcutActivator, Intent> get _shortcuts {
564-
return <ShortcutActivator, Intent>{
565-
..._commonShortcuts,
566-
..._platformShortcuts,
567-
};
568-
}
569555
}

packages/flutter/test/widgets/editable_text_test.dart

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:flutter/gestures.dart';
88
import 'package:flutter/material.dart';
99
import 'package:flutter/rendering.dart';
1010
import 'package:flutter/services.dart';
11-
import 'package:flutter/widgets.dart';
1211
import 'package:flutter_test/flutter_test.dart';
1312

1413
import '../rendering/mock_canvas.dart';
@@ -8636,71 +8635,6 @@ void main() {
86368635
await tester.pump();
86378636
expect(scrollController.offset.roundToDouble(), 0.0);
86388637
});
8639-
8640-
// Regression test for https://github.com/flutter/flutter/issues/90907.
8641-
testWidgets("ActivateIntent doesn't block space entry", (WidgetTester tester) async {
8642-
final FocusNode focusNode = FocusNode();
8643-
bool invoked = false;
8644-
8645-
await tester.pumpWidget(MaterialApp(
8646-
home: Scaffold(
8647-
body: Align(
8648-
alignment: Alignment.topLeft,
8649-
child: SizedBox(
8650-
width: 100,
8651-
child: ListTile(
8652-
title: Actions(
8653-
actions: <Type, Action<Intent>>{
8654-
ActivateIntent: CallbackAction<ActivateIntent>(
8655-
onInvoke: (ActivateIntent intent) {
8656-
invoked = true;
8657-
},
8658-
),
8659-
},
8660-
child: Column(
8661-
children: <Widget>[
8662-
EditableText(
8663-
autofocus: true,
8664-
showSelectionHandles: true,
8665-
maxLines: 2,
8666-
controller: TextEditingController(),
8667-
focusNode: FocusNode(),
8668-
cursorColor: Colors.red,
8669-
backgroundCursorColor: Colors.blue,
8670-
style: Typography.material2018(platform: TargetPlatform.android).black.subtitle1!.copyWith(fontFamily: 'Roboto'),
8671-
keyboardType: TextInputType.text,
8672-
),
8673-
Focus(
8674-
focusNode: focusNode,
8675-
child: const Text('Hello'),
8676-
),
8677-
],
8678-
),
8679-
),
8680-
),
8681-
),
8682-
),
8683-
),
8684-
));
8685-
8686-
await tester.sendKeyEvent(LogicalKeyboardKey.space);
8687-
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
8688-
await tester.pump();
8689-
expect(invoked, isFalse);
8690-
8691-
focusNode.requestFocus();
8692-
await tester.pump();
8693-
await tester.sendKeyEvent(LogicalKeyboardKey.space);
8694-
await tester.pump();
8695-
expect(invoked, isTrue);
8696-
8697-
invoked = false;
8698-
await tester.pump();
8699-
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
8700-
await tester.pump();
8701-
// On the web, enter doesn't activate any controls except for buttons.
8702-
expect(invoked, kIsWeb ? isFalse : isTrue);
8703-
});
87048638
}
87058639

87068640
class UnsettableController extends TextEditingController {

0 commit comments

Comments
 (0)