From 7b5ce5e1981d5ae16f10bf831b70615cb75bf567 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Tue, 13 Feb 2024 22:27:36 +0100 Subject: [PATCH] Select2: add option to close when clearing selection (#3870) --- src/pretix/static/pretixcontrol/js/ui/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pretix/static/pretixcontrol/js/ui/main.js b/src/pretix/static/pretixcontrol/js/ui/main.js index 61dfefefc..2e81dbcbe 100644 --- a/src/pretix/static/pretixcontrol/js/ui/main.js +++ b/src/pretix/static/pretixcontrol/js/ui/main.js @@ -613,6 +613,13 @@ var form_handlers = function (el) { }, 50); } }); + if ($s[0].hasAttribute("data-close-on-clear")) { + $s.on("select2:clear", function () { + window.setTimeout(function () { + $s.select2('close'); + }, 50); + }); + } }); el.find('[data-model-select2=event]').each(function () {