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
The problem can also be seen if the SpecifyDueDate preference is disabled.
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.
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>
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)
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>
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.
Pushed for 24.05! Well done everyone, thank you!
Pushed to 23.11.x for 23.11.06