Bug 36494 - Flatpickr error on checkout page if the patron is blocked from checking out
Summary: Flatpickr error on checkout page if the patron is blocked from checking out
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact: Emily Lamancusa (emlam)
URL:
Keywords:
Depends on: 18885
Blocks: 36459
  Show dependency treegraph
 
Reported: 2024-04-02 16:54 UTC by Owen Leonard
Modified: 2024-11-15 01:13 UTC (History)
7 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:
24.05.00,23.11.06
Circulation function:


Attachments
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out (2.14 KB, patch)
2024-04-02 17:17 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out (2.19 KB, patch)
2024-04-04 21:33 UTC, David Nind
Details | Diff | Splinter Review
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out (2.26 KB, patch)
2024-04-11 14:13 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2024-04-02 16:54:10 UTC
The change made by Bug 18885 can fail if the patron is restricted or expired. In that situation, the #duedatespec input doesn't exist, and trying to apply a Flatpickr configuration to it causes an error in the console:

Uncaught TypeError: can't access property "_flatpickr", document.querySelector(...) is null
Comment 1 Owen Leonard 2024-04-02 17:11:07 UTC
The problem can also be seen if the SpecifyDueDate preference is disabled.
Comment 2 Owen Leonard 2024-04-02 17:17:28 UTC
Created attachment 164286 [details] [review]
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out

This patch add some error-handling to the recent change to
circulation.tt where we handle dates and on-site checkouts. This
prevents an error in the console when the patron is blocked and the
"specify due date" field is hidden.

To test, apply the patch and make sure OnSiteCheckouts is enabled.

- Go to Circulation and check out to a patron.
- Under the restrictions tab, add a manual restriction.
- When the page reloads and the checkout form is no longer visible,
  confirm that there is no error in the browser console.

Confirm that the Bug 18885 test plan still works.
Comment 3 David Nind 2024-04-04 21:33:33 UTC
Created attachment 164440 [details] [review]
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out

This patch add some error-handling to the recent change to
circulation.tt where we handle dates and on-site checkouts. This
prevents an error in the console when the patron is blocked and the
"specify due date" field is hidden.

To test, apply the patch and make sure OnSiteCheckouts is enabled.

- Go to Circulation and check out to a patron.
- Under the restrictions tab, add a manual restriction.
- When the page reloads and the checkout form is no longer visible,
  confirm that there is no error in the browser console.

Confirm that the Bug 18885 test plan still works.

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2024-04-04 21:45:12 UTC
Testing notes:

1. I could also generate the console errors by going to Circulation > Check out[1]

2. I also encounter thus error, but maybe not related to this bug(?) - this was only in Chrome-based browsers, not Firefox:
   . Patch applied
   . Add a restriction to a patron ([any patron] > Check out > Restrictions tab (for the comment, add the text 'Test')
   . Remove the restriction
   . Add a restriction again, this time use the 'autocomplete'/prompt that comes up with previously entered values for comment field and select 'Test' again
  . I get this error (I couldn't always reproduce it):
    shortcut_23.1200015.js:46 Uncaught ReferenceError: code is not defined
    at HTMLDocument.func (shortcut_23.1200015.js:46:49)


[1] Console errors displayed in Ciruclation > Check out:

jQuery.Deferred exception: Cannot read properties of null (reading '_flatpickr') TypeError: Cannot read properties of null (reading '_flatpickr')
    at toggle_onsite_checkout (http://127.0.0.1:8081/cgi-bin/koha/circ/circulation.pl:1923:74)
    at HTMLDocument.<anonymous> (http://127.0.0.1:8081/cgi-bin/koha/circ/circulation.pl:1955:13)
    at e (http://127.0.0.1:8081/intranet-tmpl/lib/jquery/jquery-3.6.0.min_23.1200015.js:2:30038)
    at t (http://127.0.0.1:8081/intranet-tmpl/lib/jquery/jquery-3.6.0.min_23.1200015.js:2:30340) undefined
 
Uncaught TypeError: Cannot read properties of null (reading '_flatpickr')
    at toggle_onsite_checkout (circulation.pl:1923:74)
    at HTMLDocument.<anonymous> (circulation.pl:1955:13)
    at e (jquery-3.6.0.min_23.1200015.js:2:30038)
    at t (jquery-3.6.0.min_23.1200015.js:2:30340)
Comment 5 Emily Lamancusa (emlam) 2024-04-11 14:13:44 UTC
Created attachment 164734 [details] [review]
Bug 36494: Flatpickr error on checkout page if the patron is blocked from checking out

This patch add some error-handling to the recent change to
circulation.tt where we handle dates and on-site checkouts. This
prevents an error in the console when the patron is blocked and the
"specify due date" field is hidden.

To test, apply the patch and make sure OnSiteCheckouts is enabled.

- Go to Circulation and check out to a patron.
- Under the restrictions tab, add a manual restriction.
- When the page reloads and the checkout form is no longer visible,
  confirm that there is no error in the browser console.

Confirm that the Bug 18885 test plan still works.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 6 Emily Lamancusa (emlam) 2024-04-11 14:52:19 UTC
Nice catch! Passing QA

It looks like the error David found is unrelated and comes from our keydown event handling in shortcut.js...we check both e.keyCode and e.which to determine which key was pressed, but (according to a bit of googling) they don't play nice with special keys. They're also both deprecated D: (though it looks like no one has dropped support for them yet) Filing bug bug 36580 to put it on the radar.
Comment 7 Katrin Fischer 2024-04-12 10:13:04 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 8 Fridolin Somers 2024-05-22 14:10:53 UTC
Pushed to 23.11.x for 23.11.06