Skip to content

et2date: Re-create Flatpickr after the widget is moved in the DOMFix et2date - #263

Open
asig2016 wants to merge 2 commits into
EGroupware:masterfrom
asig2016:fix_et2date
Open

et2date: Re-create Flatpickr after the widget is moved in the DOMFix et2date#263
asig2016 wants to merge 2 commits into
EGroupware:masterfrom
asig2016:fix_et2date

Conversation

@asig2016

@asig2016 asig2016 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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.

asig2016 and others added 2 commits August 3, 2026 13:42
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>
@asig2016 asig2016 closed this Aug 3, 2026
@asig2016 asig2016 reopened this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant