Unverified Commit 69495255 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Show keyboard after text input connection restarts (#96541)

parent 5f118018
...@@ -2311,6 +2311,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -2311,6 +2311,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
final TextStyle style = widget.style; final TextStyle style = widget.style;
newConnection newConnection
..show()
..setStyle( ..setStyle(
fontFamily: style.fontFamily, fontFamily: style.fontFamily,
fontSize: style.fontSize, fontSize: style.fontSize,
......
...@@ -2194,6 +2194,49 @@ void main() { ...@@ -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( testWidgets(
'iOS autocorrection rectangle should appear on demand and dismiss when the text changes or when focus is lost', 'iOS autocorrection rectangle should appear on demand and dismiss when the text changes or when focus is lost',
(WidgetTester tester) async { (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment