mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-13 12:23:44 +01:00
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:
1 parent
9f4ea846fd
commit
26d0751df6
1 file changed
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user