fix(datepicker): reset a stale overlay before reattaching it

Navigating back while a mobile picker was open reattached its overlay still
active, leaving the page covered by an overlay nothing could close. Also skip
the reattach when the global container doesn't exist yet.
This commit is contained in:
Herculino Trotta committed 2026-11-08 02:25:31 -03:00
1 parent 9f4ea846fd
commit 26d0751df6
1 file changed
+4 -2
+4 -2
View File
@@ -117,8 +117,10 @@ let mobileOverlay = null;
function createAirDatepicker(element, opts) {
const datepicker = new AirDatepicker(element, opts);
mobileOverlay ??= document.querySelector('.air-datepicker-overlay');
if (mobileOverlay && !mobileOverlay.isConnected) {
document.getElementById(AirDatepicker.defaultGlobalContainerId).appendChild(mobileOverlay);
const container = document.getElementById(AirDatepicker.defaultGlobalContainerId);
if (mobileOverlay && !mobileOverlay.isConnected && container) {
mobileOverlay.classList.remove('-active-'); // its picker was swapped out while open
container.appendChild(mobileOverlay);
}
return datepicker;
}