@@ -206,6 +206,7 @@ export function setupTagging({
206
206
// Show all suggestions if input is empty, or filtered if not
207
207
const query = input . value . trim ( ) . toLowerCase ( ) ;
208
208
suggestionsBox . innerHTML = "" ;
209
+
209
210
// Filter as in your input event
210
211
const filtered = autocompleteSource . filter (
211
212
( tag ) =>
@@ -320,6 +321,14 @@ export function setupTagging({
320
321
}
321
322
}
322
323
} ) ;
324
+ input . addEventListener ( "blur" , ( ) => {
325
+ const value = input . value . trim ( ) ;
326
+ if ( value !== "" ) {
327
+ // Reuse Enter key handling
328
+ input . dispatchEvent ( new KeyboardEvent ( "keydown" , { key : "Enter" } ) ) ;
329
+ }
330
+ // input.style.display = "none";
331
+ } ) ;
323
332
324
333
// Update hidden input and JSON
325
334
function updateHidden ( ) {
@@ -642,9 +651,11 @@ export function enableEditableTagsInTable() {
642
651
// Hide input when empty and blurred
643
652
if ( ! input . dataset . bound ) {
644
653
input . addEventListener ( "blur" , ( ) => {
645
- if ( input . value . trim ( ) === "" ) {
646
- input . style . display = "none" ;
654
+ const value = input . value . trim ( ) ;
655
+ if ( value !== "" ) {
656
+ input . dispatchEvent ( new KeyboardEvent ( "keydown" , { key : "Enter" } ) ) ;
647
657
}
658
+ input . style . display = "none" ;
648
659
} ) ;
649
660
650
661
input . dataset . bound = "true" ; // ✅ Prevent rebinding blur
0 commit comments