et2date: Re-create Flatpickr after the widget is moved in the DOMFix et2date - #263
Open
asig2016 wants to merge 2 commits into
Open
et2date: Re-create Flatpickr after the widget is moved in the DOMFix et2date#263asig2016 wants to merge 2 commits into
asig2016 wants to merge 2 commits into
Conversation
Since Flatpickr construction got deferred, two problems showed up when a template is loaded into a framework tab (eg. acilog edit): the date inputs showed the raw server value (2026-07-10T08:15:00Z) until the user clicked into them. - disconnectedCallback() destroys Flatpickr, which puts the unformatted value back into the input. Nothing re-created it on re-connect, so remember it and init() again when we come back. - init() is async and called from updated(), so two calls could run at once. The second one bound Flatpickr to the first instance's altInput and left the first instance (and its calendar) behind. Keep the running promise and let further calls join it. Co-Authored-By: Claude Opus 5 (1M context)
Leak check on the previous commit found it orphaned one Flatpickr calendar in <body> per date widget every time a framework tab was closed: teardown briefly re-attaches the nodes, the re-init scheduled in connectedCallback() then completed after the final removal, and nothing was left to destroy the new instance. Guard init() and the spot after its awaits with isConnected and push the re-init to the next connectedCallback() instead. Also remove the listeners init() actually added - it removed this._onChange, which does not exist, so _updateValueOnChange piled up on the input across reconnect cycles. Verified in the browser over four tab open/close cycles: calendars in <body> now always match the live date widgets (was growing by ~7 per cycle). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Flatpickr construction got deferred, α problem showed up when a template is loaded into a
framework tab: the date inputs showed the raw server value (2026-07-10T08:15:00Z)
until the user clicked into them.