Bug 29450

Summary: Allow flatPickr to instantiate in any order
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: TemplatesAssignee: Martin Renvoize <martin.renvoize>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 29450: Allow flatpickr to instantiate in any order
Bug 29450: Allow flatpickr to instantiate in any order

Description Martin Renvoize 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 2021-11-10 11:06:18 UTC Comment hidden (obsolete)
Comment 2 Martin Renvoize 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 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!