Repository navigation
Conversation
Vanilla Calendar Pro builds its popup on the first click or focus of the trigger. Until then `context.mainElement` is still the trigger itself. `set()` (a prefilled input value, `setSelectedDates()`) marks the calendar as rendered, so VCP's `show()` skips its own first-click fallback and positions the trigger instead of the popup: it writes `data-vc-position` and inline `left`/`top` onto the input, where `[data-vc-position="bottom"]` adds a top margin and the field jumps down by 4px the moment it receives focus. The attributes are never removed. Inside `.form-adorn` the wrapper gets them instead. Click the trigger first when VCP has not built its popup yet, as VCP does itself for an empty input, so the popup exists before it is positioned. Scope the position margins to the calendar element so a stray attribute on a trigger can no longer move it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
A datepicker
<input>with avalueattribute jumps down by 4px the moment it receives focus, and stays there. The same happens aftersetSelectedDates()is called before the popup has been opened once. Inside.form-adornthe wrapper is affected instead of the input.Vanilla Calendar Pro builds its popup lazily, on the first click or focus of the trigger. Until then
context.mainElementis still the trigger itself.set()(which_parseInputValue()andsetSelectedDates()call) marks the calendar as rendered, so VCP'sshow()skips its own first-click fallback and runs its positioning helper on the trigger:data-vc-position="bottom"plus inlineleft/topland on the input. Bootstrap's unscoped[data-vc-position="bottom"] { margin-block-start: .25rem }then matches the input and pushes it down. An empty input is not affected because VCP's fallback clicks the trigger first, which creates the popup.This PR:
Datepicker#show()click the trigger first when VCP has not built its popup yet (context.inputModeInitis unset), mirroring what VCP does for an empty input, so the popup exists before it is positioned. A button trigger's click already runs the data API and shows the popup, soshow()returns in that case instead of firingshowntwice._datepicker.scssto[data-vc="calendar"], so a stray attribute on a trigger can no longer move it.setSelectedDates()before the first show, a prefilled input inside.form-adorn, focus via the data API, and a button shown programmatically before its first click. All five fail onmain.Motivation & Context
Reproduction with the
6.0.0-alpha.1CDN build: take the datepicker example from the docs and addvalue="2026-08-04"to the input. Click it: the field moves down 4px as the focus ring appears and the input now carriesdata-vc-position="bottom"andstyle="left: …; top: …". Remove thevalueand it does not move. Server-rendered forms (edit pages) nearly always prefill the value, so this hits most real-world uses of the datepicker.Verified in Chrome with the built
distthat the input, a.form-adornwrapper, and a button trigger no longer move or receive VCP attributes, while the popup still opens and is positioned below the trigger.The underlying cause is arguably in VCP (its
show()guards oncurrentTypeinstead ofinputModeInit), but Bootstrap can avoid it on its side without waiting for an upstream release.Type of changes
Checklist
npm run lint)Live previews
Related issues
None found.
EDIT:
https://codepen.io/editor/aloysiu5/pen/01a14f9c-e218-7ffa-bcc8-5179618dd13a
🤖 Generated with Claude Code