From fadb37d3e1a4218dd8d35cf63c5c491b4c5e9e7c Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 10 Jan 2024 12:20:28 +0000 Subject: [PATCH] Bug 35329: (follow-up) Trigger Select2 upon modal open If we wait until the modal is visible Select2 can correctly calculate the width needed for the Sort 1 and Sort 2 dropdowns. Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- .../intranet-tmpl/prog/en/includes/patron-search.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 931fca48bf..85980b6dc3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -239,9 +239,15 @@ var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; [% END %] - $(document).ready(function() { + $(document).on("shown.bs.modal", function(){ $('select[name="sort1_filter"]').select2({allowClear:true}); $('select[name="sort2_filter"]').select2({allowClear:true}); + }).on("hidden.bs.modal", function(){ + ["sort1_filter", "sort2_filter"].forEach(function(item){ + if( $('select[name=' + item + ']').data("select2") ){ + $('select[name=' + item + ']').select2("destroy"); + } + }); }); -- 2.39.5