JS Date Picker in <dialog>

Anyone know of a JS date picker component/widget that works in the <dialog> element? FlatPickr and AirPicker all fail as the calendar is rendered outside of the top layer.
3 Replies
Jochem
Jochemβ€’2mo ago
how about <input type="date">?
βœ«π•½π–†π–Œπ–Šπ–— ✫
The issue with Flatpickr, AirPicker, and similar components is that they often append their calendar dropdown to the document body, which ignores the <dialog>'s top layer positioning, causing them to display outside of it. Flatpickr has a appendTo option to set the parent element of the calendar dropdown. Instead of the body, try appending it to the dialog itself: flatpickr(".your-input", { appendTo: document.querySelector("dialog"), // other options }); This should help keep it inside the dialog if you specify the <dialog> element directly. OR (TRY THIS) Custom CSS with position: relative; on <dialog>: For any picker, you could add position: relative; to the <dialog> itself, giving it a new context, and setting the date picker’s container position as absolute.
ἔρως
ἔρως‒2mo ago
actually, do not do it to the dialog itself add a wrapper and then set it to the wrapper but the correct way is what he said: configure the parent element for the datepickers inside the dialog
Want results from more Discord servers?
Add your server