@@ -1013,6 +1013,55 @@ void testMain() {
10131013 expect (formsOnTheDom, hasLength (1 ));
10141014 });
10151015
1016+ test (
1017+ 'singleTextField Autofill setEditableSizeAndTransform preserves'
1018+ 'editing state' , () {
1019+ // Create a configuration with focused element has autofil hint.
1020+ final Map <String , dynamic > flutterSingleAutofillElementConfig =
1021+ createFlutterConfig ('text' , autofillHint: 'username' );
1022+ final MethodCall setClient = MethodCall ('TextInput.setClient' ,
1023+ < dynamic > [123 , flutterSingleAutofillElementConfig]);
1024+ sendFrameworkMessage (codec.encodeMethodCall (setClient));
1025+
1026+ const MethodCall setEditingState1 =
1027+ MethodCall ('TextInput.setEditingState' , < String , dynamic > {
1028+ 'text' : 'abcd' ,
1029+ 'selectionBase' : 2 ,
1030+ 'selectionExtent' : 3 ,
1031+ });
1032+ sendFrameworkMessage (codec.encodeMethodCall (setEditingState1));
1033+
1034+ const MethodCall show = MethodCall ('TextInput.show' );
1035+ sendFrameworkMessage (codec.encodeMethodCall (show));
1036+
1037+ // The second [setEditingState] should override the first one.
1038+ checkInputEditingState (
1039+ textEditing.editingElement.domElement, 'abcd' , 2 , 3 );
1040+
1041+ // The transform is changed. For example after a validation error, red
1042+ // line appeared under the input field.
1043+ final MethodCall setSizeAndTransform =
1044+ configureSetSizeAndTransformMethodCall (150 , 50 ,
1045+ Matrix4 .translationValues (10.0 , 20.0 , 30.0 ).storage.toList ());
1046+ sendFrameworkMessage (codec.encodeMethodCall (setSizeAndTransform));
1047+
1048+ // Check the element still has focus. User can keep editing.
1049+ expect (document.activeElement, textEditing.editingElement.domElement);
1050+
1051+ // Check the cursor location is the same.
1052+ checkInputEditingState (
1053+ textEditing.editingElement.domElement, 'abcd' , 2 , 3 );
1054+
1055+ const MethodCall clearClient = MethodCall ('TextInput.clearClient' );
1056+ sendFrameworkMessage (codec.encodeMethodCall (clearClient));
1057+
1058+ // Confirm that [HybridTextEditing] didn't send any messages.
1059+ expect (spy.messages, isEmpty);
1060+ // Form stays on the DOM until autofill context is finalized.
1061+ expect (document.getElementsByTagName ('form' ), isNotEmpty);
1062+ expect (formsOnTheDom, hasLength (1 ));
1063+ });
1064+
10161065 test (
10171066 'multiTextField Autofill: setClient, setEditingState, show, '
10181067 'setEditingState, clearClient' , () {
0 commit comments