Skip to content

Commit ccbab73

Browse files
committed
fix: autosubmit only if the suggestion is closed
1 parent ee71399 commit ccbab73

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

asset/js/widget/Completer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,15 @@ define(["../notjQuery"], function ($) {
478478
}
479479

480480
onFocusOut(event) {
481-
// Autosubmit when the user leaves the input without selecting a suggestion on manually changing the value.
481+
// Autosubmit if the user leaves the input and the input has been manually changed.
482482
// Only for non-instrumented mode — instrumented inputs (e.g. TermInput) handle
483483
// autosubmit themselves via BaseInput.autoSubmit() with proper term data.
484484
if (! this.instrumented && this.hasBeenManuallyChanged && this.shouldAutoSubmit()) {
485485
this.hasBeenManuallyChanged = false;
486486
let input = event.target;
487487
setTimeout(() => {
488488
$(input.form).trigger('submit', { submittedBy: input });
489-
}, 250);
489+
}, 300);
490490
}
491491

492492
if (this.completedInput === null) {
@@ -511,6 +511,7 @@ define(["../notjQuery"], function ($) {
511511
}
512512

513513
this.hideSuggestions();
514+
this.hasBeenManuallyChanged = true;
514515
}
515516
}, 250);
516517
}
@@ -668,6 +669,7 @@ define(["../notjQuery"], function ($) {
668669
break;
669670
case 'Tab':
670671
suggestions = this.termSuggestions.querySelectorAll('[type="button"]');
672+
this.hasBeenManuallyChanged = false;
671673
if (suggestions.length === 1) {
672674
event.preventDefault();
673675
let input = event.target;
@@ -696,6 +698,7 @@ define(["../notjQuery"], function ($) {
696698
break;
697699
case 'ArrowUp':
698700
suggestions = this.termSuggestions.querySelectorAll('[type="button"]');
701+
this.hasBeenManuallyChanged = false;
699702
if (suggestions.length) {
700703
event.preventDefault();
701704
this.moveToSuggestion(true);
@@ -704,6 +707,7 @@ define(["../notjQuery"], function ($) {
704707
break;
705708
case 'ArrowDown':
706709
suggestions = this.termSuggestions.querySelectorAll('[type="button"]');
710+
this.hasBeenManuallyChanged = false;
707711
if (suggestions.length) {
708712
event.preventDefault();
709713
this.moveToSuggestion();

0 commit comments

Comments
 (0)