Bug 32204 - in-page anchor to edititem on additem.pl not working
Summary: in-page anchor to edititem on additem.pl not working
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Lucas Gass (lukeg)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-14 23:56 UTC by Lucas Gass (lukeg)
Modified: 2023-12-28 20:44 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.03
Circulation function:


Attachments
Bug 32204: Check for hash before setting focus (1.92 KB, patch)
2023-01-10 18:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 32204: Check for hash before setting focus (1.96 KB, patch)
2023-01-10 19:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 32204: Check for hash before setting focus (2.02 KB, patch)
2023-01-23 13:23 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass (lukeg) 2022-11-14 23:56:32 UTC
To recreate:

1. Search the catalog and view a record detail page of a record with items
2. Click 'Edit items'
3. Choose one item from the list and click 'Edit'
4. The URL fragment or in-page anchor (#edititem) is appended to the end of the URL but you are not placed on it. Instead you are placed at the top of the page and must scroll down to edit the particular item.

Note: This issue is present in master and 22.05.x, as far as I can tell.
Comment 2 Lucas Gass (lukeg) 2022-11-29 21:39:06 UTC
For me the empty searchid parameter doesn't seem to matter.

If I click 'Edit item', I am still at the top of the page ( fragment doesn't work )

but if I then go to the address bar and press return to refresh I am taken to the #edititem location. ( fragment does work )
Comment 3 Nick Clemens (kidclamp) 2022-12-23 15:36:23 UTC
I believe it is the tabs:
koha-tmpl/intranet-tmpl/prog/js/staff-global.js
 51 $(document).ready(function() {
 52     $('#header_search').tabs({
 53         create: function( e, ui ){
 54             ui.panel.find("input:text:first").focus();
 55         },
 56         activate: function ( e, ui ) {
 57             ui.newPanel.find("input:text:first").focus();
 58         }
 59     });

They are moving the focus to the header search when the tabs are loaded - refreshing from the url doesn't fully reload the page, so the anchor works as we don't trigger the focus
Comment 4 Liz Rea 2022-12-23 15:55:53 UTC
Confirmed 22.05.07 and up
Comment 5 Lucas Gass (lukeg) 2023-01-10 18:07:22 UTC
(In reply to Nick Clemens from comment #3)
> I believe it is the tabs:
> koha-tmpl/intranet-tmpl/prog/js/staff-global.js
>  51 $(document).ready(function() {
>  52     $('#header_search').tabs({
>  53         create: function( e, ui ){
>  54             ui.panel.find("input:text:first").focus();
>  55         },
>  56         activate: function ( e, ui ) {
>  57             ui.newPanel.find("input:text:first").focus();
>  58         }
>  59     });
> 
> They are moving the focus to the header search when the tabs are loaded -
> refreshing from the url doesn't fully reload the page, so the anchor works
> as we don't trigger the focus

100% correct. I think we could check for the existence of a hash before we set the focus.
Comment 6 Lucas Gass (lukeg) 2023-01-10 18:12:27 UTC
Created attachment 145200 [details] [review]
Bug 32204: Check for hash before setting focus

1. Search the catalog and view a record detail page of a record with items
2. Click 'Edit items'
3. Choose one item from the list and click 'Edit'
4. The URL fragment or in-page anchor (#edititem) is appended to the end of the URL but you are not placed on it. Instead you are placed at the top of the page and must scroll down to edit the particular item.
5. Apply patch
6. Try steps 1 - 3 again, now you should be placed in the correct location (#edititem) when editing an item.
Comment 7 Lucas Gass (lukeg) 2023-01-10 18:53:46 UTC
This does interrupt workflows so I am setting the importance to normal.
Comment 8 David Nind 2023-01-10 19:48:04 UTC
Created attachment 145203 [details] [review]
Bug 32204: Check for hash before setting focus

1. Search the catalog and view a record detail page of a record with items
2. Click 'Edit items'
3. Choose one item from the list and click 'Edit'
4. The URL fragment or in-page anchor (#edititem) is appended to the end of the URL but you are not placed on it. Instead you are placed at the top of the page and must scroll down to edit the particular item.
5. Apply patch
6. Try steps 1 - 3 again, now you should be placed in the correct location (#edititem) when editing an item.

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 Nick Clemens (kidclamp) 2023-01-23 13:23:01 UTC
Created attachment 145572 [details] [review]
Bug 32204: Check for hash before setting focus

1. Search the catalog and view a record detail page of a record with items
2. Click 'Edit items'
3. Choose one item from the list and click 'Edit'
4. The URL fragment or in-page anchor (#edititem) is appended to the end of the URL but you are not placed on it. Instead you are placed at the top of the page and must scroll down to edit the particular item.
5. Apply patch
6. Try steps 1 - 3 again, now you should be placed in the correct location (#edititem) when editing an item.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Tomás Cohen Arazi (tcohen) 2023-01-27 18:21:27 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 11 Matt Blenkinsop 2023-01-31 14:23:19 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 12 Lucas Gass (lukeg) 2023-02-01 16:25:32 UTC
This fix does not work with 22.05.x, no backport.