mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-06 11:45:48 +08:00
Bugfix: close popups on browser back/forward hash change
This commit is contained in:
parent
985a4f5077
commit
631b487163
1 changed files with 9 additions and 4 deletions
|
@ -4,7 +4,7 @@ import { doc, $htmlCL } from 'Common/Globals';
|
||||||
import { arrayLength, isFunction } from 'Common/Utils';
|
import { arrayLength, isFunction } from 'Common/Utils';
|
||||||
|
|
||||||
let currentScreen = null,
|
let currentScreen = null,
|
||||||
popupsVisible = 0,
|
visiblePopups = new Set,
|
||||||
defaultScreenName = '';
|
defaultScreenName = '';
|
||||||
|
|
||||||
const SCREENS = {},
|
const SCREENS = {},
|
||||||
|
@ -61,7 +61,7 @@ const SCREENS = {},
|
||||||
|
|
||||||
vm.modalVisibility.subscribe(value => {
|
vm.modalVisibility.subscribe(value => {
|
||||||
if (value) {
|
if (value) {
|
||||||
++popupsVisible;
|
visiblePopups.add(vm);
|
||||||
vmDom.style.zIndex = 3000 + popupVisibilityNames().length + 10;
|
vmDom.style.zIndex = 3000 + popupVisibilityNames().length + 10;
|
||||||
vmDom.hidden = false;
|
vmDom.hidden = false;
|
||||||
vm.storeAndSetScope();
|
vm.storeAndSetScope();
|
||||||
|
@ -71,7 +71,7 @@ const SCREENS = {},
|
||||||
vmDom.classList.add('show'); // trigger the transitions
|
vmDom.classList.add('show'); // trigger the transitions
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
popupsVisible = Math.max(0, popupsVisible-1);
|
visiblePopups.delete(vm);
|
||||||
vm.onHide && vm.onHide();
|
vm.onHide && vm.onHide();
|
||||||
vmDom.classList.remove('show');
|
vmDom.classList.remove('show');
|
||||||
vm.restoreScope();
|
vm.restoreScope();
|
||||||
|
@ -123,6 +123,11 @@ const SCREENS = {},
|
||||||
screenName = defaultScreenName;
|
screenName = defaultScreenName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close all popups
|
||||||
|
for (let vm of visiblePopups) {
|
||||||
|
vm.closeCommand();
|
||||||
|
}
|
||||||
|
|
||||||
if (screenName) {
|
if (screenName) {
|
||||||
vmScreen = screen(screenName);
|
vmScreen = screen(screenName);
|
||||||
if (!vmScreen) {
|
if (!vmScreen) {
|
||||||
|
@ -271,7 +276,7 @@ export const
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
arePopupsVisible = () => 0 < popupsVisible,
|
arePopupsVisible = () => 0 < visiblePopups.size,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} ViewModelClassToShow
|
* @param {Function} ViewModelClassToShow
|
||||||
|
|
Loading…
Add table
Reference in a new issue