Bug 31646

Summary: Focus input by default when clicking on a dropdown field in the cataloguing editor
Product: Koha Reporter: Aleisha Amohia <aleisha>
Component: CatalogingAssignee: Lucas Gass <lucas>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: arthur.suzuki, katrin.fischer, lucas, m.de.rooy, martin.renvoize, victor
Version: unspecifiedKeywords: regression
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.07, 21.11.14
Attachments: Bug 31646: Add Select2 focus to text search field
Bug 31646: Add Select2 focus to text search field
Bug 31646: Add Select2 focus to text search field

Description Aleisha Amohia 2022-09-28 22:52:09 UTC
In Koha 21.11.x and maybe earlier, when clicking on a field that is a dropdown in the cataloguing editor, the input search field would focus automatically, putting the cursor in the box so you can start typing right away.

Since 22.05.x, this no longer happens. When you click the dropdown and it opens, you need to click again into the input search field in order to start typing.

This happens in upstream as well, the most recent version where it worked was 21.11.x. So it must've broken in 22.05.x.

To reproduce:
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
Comment 1 Katrin Fischer 2022-09-29 12:09:03 UTC
*** Bug 31429 has been marked as a duplicate of this bug. ***
Comment 2 Lucas Gass 2022-09-29 23:13:38 UTC
Do we want all dropdowns with a select2-search__field to move focus to the search input? 

With the 942$c it makes a lot of sense. But maybe with the fields like 942$n ( Suppress in OPAC ) which is a yes/no we would want the focus to stay on the dropdown options so the user can use the keyup and keydown to select either yes/no.
Comment 3 Aleisha Amohia 2022-09-29 23:20:50 UTC
I think yes we do want it to move to the search input. They can still search Y or N to get to those yes/no options.
Comment 4 Lucas Gass 2022-09-30 17:56:00 UTC
Created attachment 141175 [details] [review]
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.
Comment 5 Katrin Fischer 2022-10-01 07:56:43 UTC
Hi Lucas, please don't forget to set Assignee, thx!
Comment 6 Aleisha Amohia 2022-10-04 01:31:21 UTC
Created attachment 141293 [details] [review]
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 <aleishaamohia@hotmail.com>
Comment 7 Martin Renvoize 2022-10-07 10:45:11 UTC
Created attachment 141492 [details] [review]
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 <aleishaamohia@hotmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize 2022-10-07 10:46:00 UTC
Nice improvement, works as described.

Passing QA
Comment 9 Tomás Cohen Arazi 2022-10-11 13:24:08 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 10 Lucas Gass 2022-11-02 14:39:13 UTC
Backported to 22.05.x for upcoming 22.05.07 release
Comment 11 Arthur Suzuki 2022-11-15 17:07:29 UTC
applied to 21.11 for 21.11.14
Comment 12 Victor Grousset/tuxayo 2022-11-27 00:05:04 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document it seems, marking resolved.