Bug 29450 - Allow flatPickr to instantiate in any order
Summary: Allow flatPickr to instantiate in any order
Status: RESOLVED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-10 10:49 UTC by Martin Renvoize (ashimema)
Modified: 2024-07-15 17:54 UTC (History)
0 users

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


Attachments
Bug 29450: Allow flatpickr to instantiate in any order (2.33 KB, patch)
2021-11-10 11:06 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 29450: Allow flatpickr to instantiate in any order (2.27 KB, patch)
2021-11-15 08:36 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2021-11-10 10:49:22 UTC
Currently, we automatically instantiate a flatPickr instance for any input fields that have the flatpickr class.

This instantiation is handling within a loop and works well in most cases.  However, if the the input is paired so we have a start/end date pair and the start date is pre-populated with the template you are faced with javascript errors.

This is because the pre-populated value triggers our onClose function that resides in the instantiation settings. The onClose looks for the associated 'end' input and grabs the flatpickr instance to set the minDate property.. but as we've not yet hit the end input field the flatpicker instance for that field doesn't yet exist.
Comment 1 Martin Renvoize (ashimema) 2021-11-10 11:06:18 UTC Comment hidden (obsolete)
Comment 2 Martin Renvoize (ashimema) 2021-11-15 08:36:59 UTC
Created attachment 127621 [details] [review]
Bug 29450: Allow flatpickr to instantiate in any order

This patch updates the flatpickr wrapper code to allow for cases where
the startdate/enddate pickers are pre-populated and thus the onClose
event of the startdate pickr may be fired before the enddate flatpickr
is instantiated.. which leads to an error.
Comment 3 Martin Renvoize (ashimema) 2021-11-15 08:37:33 UTC
Removed a console.log statement I errantly left in.. otherwise, latest patch matches the previous upload.
Comment 4 Owen Leonard 2022-04-04 10:55:53 UTC
Can you remember where you observed this bug?
Comment 5 Katrin Fischer 2022-07-17 10:55:48 UTC
Hi Martin, could you please add a test plan for this?
Comment 6 Katrin Fischer 2023-06-24 22:11:40 UTC
(In reply to Katrin Fischer from comment #5)
> Hi Martin, could you please add a test plan for this?

Ping!