Skip to content

Datepicker: populate input with preselected dates on load#42628

Open
mdo wants to merge 1 commit into
v6-devfrom
datepicker-preselected-dates
Open

Datepicker: populate input with preselected dates on load#42628
mdo wants to merge 1 commit into
v6-devfrom
datepicker-preselected-dates

Conversation

@mdo

@mdo mdo commented Jul 7, 2026

Copy link
Copy Markdown
Member

Fixes #42616

data-bs-selected-dates wasn't showing up in the field until you focused it — the input just sat there with its placeholder.

The reason is that input/button datepickers are only created lazily on focus/click. Only inline datepickers get auto-initialized on DOMContentLoaded, so any preselected dates never rendered on load.

This extends the DOMContentLoaded auto-init to also grab datepickers with data-bs-selected-dates so the value populates right away. The population logic itself already worked once an instance existed.

Added a couple of tests to cover it.

Fixes #42616

Input and button datepickers are only created on focus/click, so
data-bs-selected-dates never showed up until you interacted with the
field. Only inline datepickers were auto-initialized on load.

Extend the DOMContentLoaded auto-init to also cover any datepicker with
preselected dates so the value renders immediately.
@mdo mdo requested review from a team as code owners July 7, 2026 18:00
@mdo mdo changed the base branch from main to v6-dev July 7, 2026 18:04
@mdo mdo added this to v6.0.0 Jul 7, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

data-bs-selected-dates does not populate the actual form field.

1 participant