This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 2 files changed +26
-0
lines changed
lib/src/engine/text_editing
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1369,6 +1369,10 @@ abstract class DefaultTextEditingStrategy with CompositionAwareMixin implements
1369
1369
final DomKeyboardEvent event = e as DomKeyboardEvent ;
1370
1370
if (event.keyCode == _kReturnKeyCode) {
1371
1371
onAction !(inputConfiguration.inputAction);
1372
+ // Stop key event propagation if the input type is not multiline.
1373
+ if (inputConfiguration.inputType is ! MultilineInputType ) {
1374
+ event.preventDefault ();
1375
+ }
1372
1376
}
1373
1377
}
1374
1378
}
Original file line number Diff line number Diff line change @@ -390,6 +390,28 @@ Future<void> testMain() async {
390
390
expect (event.defaultPrevented, isFalse);
391
391
});
392
392
393
+ test ('Triggers input action and prevent entre key event for single line field' , () {
394
+ // Regression test for https://github.com/flutter/flutter/issues/113559
395
+ final InputConfiguration config = InputConfiguration ();
396
+ editingStrategy! .enable (
397
+ config,
398
+ onChange: trackEditingState,
399
+ onAction: trackInputAction,
400
+ );
401
+
402
+ // No input action so far.
403
+ expect (lastInputAction, isNull);
404
+
405
+ final DomKeyboardEvent event = dispatchKeyboardEvent (
406
+ editingStrategy! .domElement! ,
407
+ 'keydown' ,
408
+ keyCode: _kReturnKeyCode,
409
+ );
410
+ expect (lastInputAction, 'TextInputAction.done' );
411
+ // And default behavior of keyboard event should have been prevented.
412
+ expect (event.defaultPrevented, isTrue);
413
+ });
414
+
393
415
test ('globally positions and sizes its DOM element' , () {
394
416
editingStrategy! .enable (
395
417
singlelineConfig,
You can’t perform that action at this time.
0 commit comments