Unverified Commit f9b8d688 authored by Gary Qian's avatar Gary Qian Committed by GitHub

Reorder show and setEditingState calls to the IMM (#43865)

parent 175b3724
...@@ -1409,6 +1409,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -1409,6 +1409,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
keyboardAppearance: widget.keyboardAppearance, keyboardAppearance: widget.keyboardAppearance,
), ),
); );
_textInputConnection.show();
_updateSizeAndTransform(); _updateSizeAndTransform();
final TextStyle style = widget.style; final TextStyle style = widget.style;
...@@ -1421,8 +1422,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -1421,8 +1422,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
textAlign: widget.textAlign, textAlign: widget.textAlign,
) )
..setEditingState(localValue); ..setEditingState(localValue);
} else {
_textInputConnection.show();
} }
_textInputConnection.show();
} }
void _closeInputConnectionIfNeeded() { void _closeInputConnectionIfNeeded() {
......
...@@ -3413,6 +3413,45 @@ void main() { ...@@ -3413,6 +3413,45 @@ void main() {
throwsAssertionError, throwsAssertionError,
); );
}); });
testWidgets('input imm channel calls are ordered correctly', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[];
SystemChannels.textInput.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
});
const String testText = 'flutter is the best!';
final TextEditingController controller = TextEditingController(text: testText);
final EditableText et = EditableText(
showSelectionHandles: true,
maxLines: 2,
controller: controller,
focusNode: FocusNode(),
cursorColor: Colors.red,
backgroundCursorColor: Colors.blue,
style: Typography(platform: TargetPlatform.android).black.subhead.copyWith(fontFamily: 'Roboto'),
keyboardType: TextInputType.text,
);
await tester.pumpWidget(MaterialApp(
home: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 100,
child: et,
),
),
));
await tester.showKeyboard(find.byType(EditableText));
expect(log.length, 7);
// TextInput.show should be before TextInput.setEditingState
final List<String> logOrder = <String>['TextInput.setClient', 'TextInput.show', 'TextInput.setEditableSizeAndTransform', 'TextInput.setStyle', 'TextInput.setEditingState', 'TextInput.setEditingState', 'TextInput.show'];
int index = 0;
for (MethodCall m in log) {
expect(m.method, logOrder[index]);
index++;
}
});
} }
class MockTextSelectionControls extends Mock implements TextSelectionControls { class MockTextSelectionControls extends Mock implements TextSelectionControls {
......
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