Skip to content

Commit 62bd487

Browse files
authored
[web] dispatch corresponding keyup events in text editing integrations (flutter#136874)
flutter/engine#46829 changed event handling sequence on web so that KeyboardBinding/RawKeyboard handles the text event first before it reaches IME. That means when dispatching synthetised events to IME every keydown event must have a corresponding keyup, otherwise consistency assertions in `KeyboardBindings` are triggered. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 8e7fce9 commit 62bd487

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ void main() {
8080
expect(textFormFieldsFinder, findsOneWidget);
8181
await tester.tap(find.byKey(const Key('input2')));
8282

83-
// // Press Tab. This should trigger `onFieldSubmitted` of TextField.
83+
// Press Tab. This should trigger `onFieldSubmitted` of TextField.
8484
final InputElement input = findElements('input')[0] as InputElement;
8585
dispatchKeyboardEvent(input, 'keydown', <String, dynamic>{
8686
'keyCode': 13, // Enter.
8787
'cancelable': true,
8888
});
89+
// Release Tab.
90+
dispatchKeyboardEvent(input, 'keyup', <String, dynamic>{
91+
'keyCode': 13, // Enter.
92+
'cancelable': true,
93+
});
8994

9095
await tester.pumpAndSettle();
9196

@@ -118,6 +123,14 @@ void main() {
118123
'cancelable': true,
119124
'composed': true,
120125
});
126+
// Release tab.
127+
dispatchKeyboardEvent(input, 'keyup', <String, dynamic>{
128+
'key': 'Tab',
129+
'code': 'Tab',
130+
'bubbles': true,
131+
'cancelable': true,
132+
'composed': true,
133+
});
121134

122135
await tester.pumpAndSettle();
123136

@@ -165,6 +178,14 @@ void main() {
165178
'cancelable': true,
166179
'composed': true,
167180
});
181+
// Release Tab.
182+
dispatchKeyboardEvent(input, 'keyup', <String, dynamic>{
183+
'key': 'Tab',
184+
'code': 'Tab',
185+
'bubbles': true,
186+
'cancelable': true,
187+
'composed': true,
188+
});
168189

169190
await tester.pumpAndSettle();
170191

0 commit comments

Comments
 (0)