@@ -6,6 +6,7 @@ define(["../notjQuery"], function ($) {
66 constructor ( input , instrumented = false ) {
77 this . input = input ;
88 this . instrumented = instrumented ;
9+ this . hasNotBeenCompleted = false ; // Flag to identify if the input has been completed at least once.
910 this . selectionStartInput = null ;
1011 this . selectionActive = false ;
1112 this . mouseSelectionActive = false ;
@@ -268,6 +269,7 @@ define(["../notjQuery"], function ($) {
268269
269270 complete ( input , value , data ) {
270271 $ ( input ) . focus ( { scripted : true } ) ;
272+ this . hasNotBeenCompleted = false ;
271273
272274 if ( this . instrumented ) {
273275 if ( ! Object . keys ( data ) . length ) {
@@ -476,7 +478,7 @@ define(["../notjQuery"], function ($) {
476478 }
477479
478480 onFocusOut ( event ) {
479- if ( this . completedInput === null ) {
481+ if ( this . completedInput === null && ( this . instrumented || ! this . hasNotBeenCompleted ) ) {
480482 // If there are multiple instances of Completer bound to the same suggestion container
481483 // all of them try to handle the event. Though, only one of them is responsible and
482484 // that's the one which has a completed input set.
@@ -492,12 +494,20 @@ define(["../notjQuery"], function ($) {
492494 && ! this . termSuggestions . contains ( document . activeElement )
493495 ) {
494496 // Hide the suggestions if the user doesn't navigate them
495- if ( input !== completedInput ) {
497+ if ( completedInput !== null && input !== completedInput ) {
496498 // Restore input if a suggestion lost focus
497499 this . suggest ( completedInput , this . completedValue ) ;
498500 }
499501
500502 this . hideSuggestions ( ) ;
503+
504+ // Autosubmit when the user leaves without selecting a suggestion on manual input.
505+ // Only for non-instrumented mode — instrumented inputs (e.g. TermInput) handle
506+ // autosubmit themselves via BaseInput.autoSubmit() with proper term data.
507+ if ( ! this . instrumented && this . shouldAutoSubmit ( ) ) {
508+ this . hasNotBeenCompleted = false ;
509+ $ ( input . form ) . trigger ( 'submit' , { submittedBy : input } ) ;
510+ }
501511 }
502512 } , 250 ) ;
503513 }
@@ -712,6 +722,7 @@ define(["../notjQuery"], function ($) {
712722
713723 onInput ( event ) {
714724 let input = event . target ;
725+ this . hasNotBeenCompleted = true ;
715726
716727 if ( input . minLength > 0 && input . value . length < input . minLength ) {
717728 return ;
0 commit comments