From 184f8d759caded591247880b83b7fe7f95d3d69d Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 30 Sep 2022 17:48:25 +0000 Subject: [PATCH] Bug 31646: Add Select2 focus to text search field To test: 1. Edit a biblio record 2. Go to tab 9 to find the item type MARC field 942$c 3. Click on the field to select an item type 4. Notice you have to click again on the search field to begin typing to search for your item type 5. Apply patch/clear browser cache 6. Try steps 2-3 again, the focus should now be on the search text field 7. Try another select2 dropdown on the same page like the 942$n ( Suppress in OPAC ), it should also default to the text search field. 8. Try other places in Koha that feature this kind of select2, like when placing hold. Note: Using $(document).on here instead of $(".select2").on becuase there are several instances where there are more than 1 select2 dropdown on a single page. This allows for the text search field to default each time you click on a different dropdown. Signed-off-by: Aleisha Amohia --- koha-tmpl/intranet-tmpl/prog/js/select2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/select2.js b/koha-tmpl/intranet-tmpl/prog/js/select2.js index 52d910a2fa..bc11558e11 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/select2.js +++ b/koha-tmpl/intranet-tmpl/prog/js/select2.js @@ -36,6 +36,10 @@ $(document).ready(function(){ $(this).off("select2:opening.cancelOpen"); }); }); + + $(document).on("select2:open", function () { + document.querySelector(".select2-container--open .select2-search__field").focus(); + }); }); (function($) { -- 2.20.1