Show keyboard after text input connection restarts (#96541)
This commit is contained in:
@@ -2311,6 +2311,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
|
||||
final TextStyle style = widget.style;
|
||||
newConnection
|
||||
..show()
|
||||
..setStyle(
|
||||
fontFamily: style.fontFamily,
|
||||
fontSize: style.fontSize,
|
||||
|
||||
@@ -2194,6 +2194,49 @@ void main() {
|
||||
])));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'requesting focus in the onSubmitted callback should keep the onscreen keyboard visible',
|
||||
(WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/95154 .
|
||||
final Widget widget = MaterialApp(
|
||||
home: EditableText(
|
||||
backgroundCursorColor: Colors.grey,
|
||||
style: Typography.material2018().black.subtitle1!,
|
||||
cursorColor: Colors.blue,
|
||||
focusNode: focusNode,
|
||||
controller: controller,
|
||||
onSubmitted: (String value) {
|
||||
focusNode.requestFocus();
|
||||
},
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(widget);
|
||||
|
||||
focusNode.requestFocus();
|
||||
await tester.pump();
|
||||
|
||||
assert(focusNode.hasFocus);
|
||||
tester.testTextInput.log.clear();
|
||||
|
||||
// This will attempt to unfocus the field but the onSubmitted callback
|
||||
// will cancel that. Restart the input connection in this case.
|
||||
await tester.testTextInput.receiveAction(TextInputAction.done);
|
||||
expect(tester.testTextInput.log, containsAllInOrder(<Matcher>[
|
||||
matchesMethodCall('TextInput.clearClient'),
|
||||
matchesMethodCall('TextInput.setClient'),
|
||||
matchesMethodCall('TextInput.show'),
|
||||
]));
|
||||
|
||||
tester.testTextInput.log.clear();
|
||||
// TextInputAction.unspecified does not unfocus the input field by default.
|
||||
await tester.testTextInput.receiveAction(TextInputAction.unspecified);
|
||||
expect(tester.testTextInput.log, isNot(containsAllInOrder(<Matcher>[
|
||||
matchesMethodCall('TextInput.clearClient'),
|
||||
matchesMethodCall('TextInput.setClient'),
|
||||
matchesMethodCall('TextInput.show'),
|
||||
])));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'iOS autocorrection rectangle should appear on demand and dismiss when the text changes or when focus is lost',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user