Bug 39400 - "Jump to add item form" doesn't work while editing an existing item
Summary: "Jump to add item form" doesn't work while editing an existing item
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Phil Ringnalda
QA Contact: Testopia
URL:
Keywords:
Depends on: 36320
Blocks:
  Show dependency treegraph
 
Reported: 2025-03-20 18:02 UTC by Katrin Fischer
Modified: 2025-03-28 18:40 UTC (History)
4 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:
Circulation function:


Attachments
Bug 39400: "Jump to add item form" doesn't work while editing an existing item (3.30 KB, patch)
2025-03-21 13:34 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 39400: "Jump to add item form" doesn't work while editing an existing item (3.36 KB, patch)
2025-03-21 15:09 UTC, Owen Leonard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2025-03-20 18:02:06 UTC
The new link to jump to the form from the top of a long item list is not working and results in a JS error.
Comment 1 Phil Ringnalda 2025-03-20 22:26:23 UTC
Are your steps to reproduce: 1. Edit an existing item, and then...?

The link targets the "<h2 id="additema">Add item</h2>" which only exists when you are not editing an existing item. The patch adding it expected that edit links would instead target #edititem, and added that target to links from the holdings table, but not from the Items tab (and I wouldn't be surprised if there are other edit item links, say in serials or acq).

But even if your edit link targets #edititem, you still might scroll up and then you'll have a broken link pretending it will take you back to the form, which should have the same conditional that determines whether to have an additema or an edititem, [% IF op != 'cud-saveitem' %]#additema[% ELSE %]#edititem[% END %].

Or, we could just target #f since the form is always there.
Comment 2 Phil Ringnalda 2025-03-20 22:46:32 UTC
Not acq (which targets #edititem) or serials (which just has a Manage items link labelled Edit items), but along with the Items tab, item search, reports which show itemnumber, and batch modify items all have links to edit a particular item without a hash to scroll to the form.
Comment 3 Katrin Fischer 2025-03-21 09:36:33 UTC
The link with the text shows right on top of the item table to the left when you edit any item in the catalog. 

I am pretty sure it's just JS.
Comment 4 Phil Ringnalda 2025-03-21 13:05:19 UTC
Ah, indeed it is JS because of bug 36320 comment 10, which would have left me very confused when I changed the link href to "f" and still scrolled to "additema" (or not, when there is no additema).
Comment 5 Phil Ringnalda 2025-03-21 13:34:35 UTC
Created attachment 179588 [details] [review]
Bug 39400: "Jump to add item form" doesn't work while editing an existing item

The link at the top of the item editor page to "Jump to add item form" tries
to scrollIntoView the element with id="additema", but that element only exists
while you are adding a new item. While you are editing an existing item, it is
replaced by an element with id="edititem". Whichever element you have at the
moment is always just below the form with id="f", so we can just scroll that
into view instead.

Test plan:
 1. Without the patch, go to the details page for any bib record with at
    least one item, and click the Edit button on the row for an item in the
    holdings table.
 2. You should be scrolled down to the form for editing that item
 3. Scroll up to the top of the page, click the Jump to add item form link
 4. You will not be scrolled back down to the form
 5. Apply patch, shift+reload page
 6. Now the link should scroll you back down to the form
 7. Return to the biblio details page, click Edit - Manage items and verify
    that the Jump to add item form link still works when you are not editing
    an existing item
 8. Click the Add multiple copies of this item button and add 30 items
 9. Make sure that the link still scrolls the form into view both while
    you are editing an existing item, and while you are adding a new item

Sponsored-by: Chetco Community Public Library
Comment 6 Owen Leonard 2025-03-21 15:09:30 UTC
Created attachment 179624 [details] [review]
Bug 39400: "Jump to add item form" doesn't work while editing an existing item

The link at the top of the item editor page to "Jump to add item form"
tries to scrollIntoView the element with id="additema", but that element
only exists while you are adding a new item. While you are editing an
existing item, it is replaced by an element with id="edititem".
Whichever element you have at the moment is always just below the form
with id="f", so we can just scroll that into view instead.

Test plan:
 1. Without the patch, go to the details page for any bib record with at
    least one item, and click the Edit button on the row for an item in
    the holdings table.
 2. You should be scrolled down to the form for editing that item
 3. Scroll up to the top of the page, click the Jump to add item form
    link
 4. You will not be scrolled back down to the form
 5. Apply patch, shift+reload page
 6. Now the link should scroll you back down to the form
 7. Return to the biblio details page, click Edit - Manage items and
    verify that the Jump to add item form link still works when you are
    not editing an existing item
 8. Click the Add multiple copies of this item button and add 30 items
 9. Make sure that the link still scrolls the form into view both while
    you are editing an existing item, and while you are adding a new item

Sponsored-by: Chetco Community Public Library
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 7 Emily Lamancusa (emlam) 2025-03-27 13:10:02 UTC
This is a nice fix, but I have one nitpick on wording: the link text still says "Jump to add item form", even when it is actually the edit form. Is there a more general phrase we could put there? Maybe "Jump to item fields form"?
Comment 8 Owen Leonard 2025-03-27 13:55:01 UTC
How about "Item entry form" ?
Comment 9 Emily Lamancusa (emlam) 2025-03-28 17:58:15 UTC
"Item entry" still sounds like adding a new item to me...I personally wouldn't call it "entry" if I was editing an existing item. I suppose we could just say "Jump to item form"?

Sorry for being so picky on this! I've just seen enough confusion about whether the page was in "add item" state or "edit item" state, and I don't want the link to add to the confusion.
Comment 10 Phil Ringnalda 2025-03-28 18:40:24 UTC
Just last night I was hoping someone would suggest "Jump to item form" so I could then top them with "Jump to form".