Space and arrow keys in a text field shouldn't scroll (#74454)
This commit is contained in:
@@ -4287,6 +4287,39 @@ void main() {
|
||||
expect(focusNode3.hasPrimaryFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Scrolling shortcuts are disabled in text fields', (WidgetTester tester) async {
|
||||
bool scrollInvoked = false;
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Actions(
|
||||
actions: <Type, Action<Intent>>{
|
||||
ScrollIntent: CallbackAction<ScrollIntent>(onInvoke: (Intent intent) {
|
||||
scrollInvoked = true;
|
||||
}),
|
||||
},
|
||||
child: ListView(
|
||||
children: const <Widget>[
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 200)),
|
||||
CupertinoTextField(),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 800)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(scrollInvoked, isFalse);
|
||||
|
||||
// Set focus on the text field.
|
||||
await tester.tapAt(tester.getTopLeft(find.byType(CupertinoTextField)));
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
expect(scrollInvoked, isFalse);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
|
||||
expect(scrollInvoked, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino text field semantics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
|
||||
@@ -8754,6 +8754,41 @@ void main() {
|
||||
expect(focusNode3.hasPrimaryFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Scrolling shortcuts are disabled in text fields', (WidgetTester tester) async {
|
||||
bool scrollInvoked = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Actions(
|
||||
actions: <Type, Action<Intent>>{
|
||||
ScrollIntent: CallbackAction<ScrollIntent>(onInvoke: (Intent intent) {
|
||||
scrollInvoked = true;
|
||||
}),
|
||||
},
|
||||
child: Material(
|
||||
child: ListView(
|
||||
children: const <Widget>[
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 200)),
|
||||
TextField(),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 800)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(scrollInvoked, isFalse);
|
||||
|
||||
// Set focus on the text field.
|
||||
await tester.tapAt(tester.getTopLeft(find.byType(TextField)));
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
expect(scrollInvoked, isFalse);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
|
||||
expect(scrollInvoked, isFalse);
|
||||
});
|
||||
|
||||
testWidgets("A buildCounter that returns null doesn't affect the size of the TextField", (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/44909
|
||||
|
||||
|
||||
Reference in New Issue
Block a user