Skip to content

fix(datepicker): fix Flatpickr 1px calendar width on hidden date pickers#1263

Merged
JohnVillalovos merged 1 commit intodevelopfrom
jlvillal/issue_1230
Apr 4, 2026
Merged

fix(datepicker): fix Flatpickr 1px calendar width on hidden date pickers#1263
JohnVillalovos merged 1 commit intodevelopfrom
jlvillal/issue_1230

Conversation

@JohnVillalovos
Copy link
Copy Markdown
Collaborator

@JohnVillalovos JohnVillalovos commented Mar 30, 2026

Flatpickr's internal setCalendarWidth() measures offsetWidth during
initialization. When a date picker lives inside a hidden ancestor
(d-none, closed Bootstrap collapse, or unopened modal), offsetWidth
returns 0, producing a 1px-wide calendar that renders as an empty
scrollbar.

Initialize Flatpickr eagerly so _flatpickr is always available to
consumers, then recalculate the calendar width once all hidden ancestors
become visible. Visibility is detected via MutationObserver for d-none
class removal, shown.bs.collapse, and shown.bs.modal events. Nested
hidden ancestors are handled recursively.

The width recalculation uses Flatpickr's public set() API:
fp.set('showMonths', fp.config.showMonths) triggers the internal
setCalendarWidth() callback, which re-measures offsetWidth at a point
where the element has its correct layout dimensions.

Closes: #1230

Copilot AI review requested due to automatic review settings March 30, 2026 00:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Flatpickr rendering for the “Repeat On” date picker when it’s initialized inside a Bootstrap d-none container (hidden at load), which previously caused the calendar to render with incorrect dimensions.

Changes:

  • Added a deferred Flatpickr initialization path when a date control has a hidden (.d-none) ancestor.
  • Implemented a MutationObserver to wait for the d-none class to be removed before calling init().

@JohnVillalovos JohnVillalovos marked this pull request as draft March 30, 2026 15:05
@JohnVillalovos JohnVillalovos marked this pull request as ready for review April 4, 2026 18:07
@JohnVillalovos JohnVillalovos requested a review from Copilot April 4, 2026 18:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@JohnVillalovos JohnVillalovos force-pushed the jlvillal/issue_1230 branch 2 times, most recently from 6fd8e54 to 2e75c26 Compare April 4, 2026 18:41
@JohnVillalovos JohnVillalovos requested a review from Copilot April 4, 2026 18:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@JohnVillalovos JohnVillalovos changed the title fix(recurrence): defer Flatpickr init for hidden repeat-on date picker fix(recurrence): defer Flatpickr init for all hidden ancestor types Apr 4, 2026
@JohnVillalovos JohnVillalovos marked this pull request as draft April 4, 2026 21:06
@JohnVillalovos JohnVillalovos changed the title fix(recurrence): defer Flatpickr init for all hidden ancestor types fix(datepicker): fix Flatpickr 1px calendar width on hidden date pickers Apr 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@JohnVillalovos JohnVillalovos requested a review from Copilot April 4, 2026 21:34
@JohnVillalovos JohnVillalovos marked this pull request as ready for review April 4, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Flatpickr's internal setCalendarWidth() measures offsetWidth during
initialization. When a date picker lives inside a hidden ancestor
(d-none, closed Bootstrap collapse, or unopened modal), offsetWidth
returns 0, producing a 1px-wide calendar that renders as an empty
scrollbar.

Initialize Flatpickr eagerly so _flatpickr is always available to
consumers, then recalculate the calendar width once all hidden ancestors
become visible. Visibility is detected via MutationObserver for d-none
class removal, shown.bs.collapse, and shown.bs.modal events. Nested
hidden ancestors are handled recursively.

The width recalculation uses Flatpickr's public set() API:
fp.set('showMonths', fp.config.showMonths) triggers the internal
setCalendarWidth() callback, which re-measures offsetWidth at a point
where the element has its correct layout dimensions.

Closes: #1230
Copy link
Copy Markdown
Collaborator

@labmecanicatec labmecanicatec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works correctly.

@JohnVillalovos JohnVillalovos merged commit 259bc36 into develop Apr 4, 2026
16 checks passed
@JohnVillalovos JohnVillalovos deleted the jlvillal/issue_1230 branch April 4, 2026 21:57
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.

Reservation - Repeat - Custom empty

3 participants