diff --git a/contao/templates/frontend/event_filter.html.twig b/contao/templates/frontend/event_filter.html.twig
index 12eb5b8..5f280cf 100644
--- a/contao/templates/frontend/event_filter.html.twig
+++ b/contao/templates/frontend/event_filter.html.twig
@@ -135,6 +135,8 @@
return null;
}
+ let shouldBlurOnChange = false;
+
return new window.TomSelect(selectElement, {
create: false,
sortField: {
@@ -149,6 +151,30 @@
return '
Keine weiteren Ergebnisse
';
},
},
+ 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;
+ },
});
};