Compare commits

...

1 Commits

Author SHA1 Message Date
Jürgen Mummert b714bbeb1b Blur Tom Select only for mouse and touch selection 2026-02-23 21:22:59 +01:00
@@ -135,6 +135,8 @@
return null; return null;
} }
let shouldBlurOnChange = false;
return new window.TomSelect(selectElement, { return new window.TomSelect(selectElement, {
create: false, create: false,
sortField: { sortField: {
@@ -149,6 +151,30 @@
return '<div class="no-more-results" role="option" aria-disabled="true">Keine weiteren Ergebnisse</div>'; return '<div class="no-more-results" role="option" aria-disabled="true">Keine weiteren Ergebnisse</div>';
}, },
}, },
onInitialize() {
const markPointerInteraction = () => {
shouldBlurOnChange = true;
};
const markKeyboardInteraction = () => {
shouldBlurOnChange = false;
};
this.control.addEventListener('pointerdown', markPointerInteraction);
this.control.addEventListener('touchstart', markPointerInteraction, { passive: true });
this.control.addEventListener('keydown', markKeyboardInteraction);
this.dropdown.addEventListener('pointerdown', markPointerInteraction);
this.dropdown.addEventListener('touchstart', markPointerInteraction, { passive: true });
this.dropdown.addEventListener('keydown', markKeyboardInteraction);
},
onChange() {
if (!shouldBlurOnChange) {
return;
}
this.blur();
shouldBlurOnChange = false;
},
}); });
}; };