properly update hash when closing UI
This commit is contained in:
parent
bcc98d913b
commit
9e009726c5
|
@ -11,14 +11,16 @@ const router = {
|
|||
return new URLSearchParams(location.search).get(key);
|
||||
},
|
||||
|
||||
/** When showing the UI, `showHide` function must resolve only when the UI is closed */
|
||||
makeToggle(hashId, showHide, deps) {
|
||||
const hash = '#' + hashId;
|
||||
const selector = '.' + hash.slice(1);
|
||||
const selector = '.' + hashId;
|
||||
router.watch({hash}, async state => {
|
||||
const el = $(selector);
|
||||
if (!state === !el) return;
|
||||
if (state && deps) await require(deps);
|
||||
await showHide(state, el, selector);
|
||||
if (state) router.updateHash('');
|
||||
});
|
||||
return router.updateHash.bind(router, hash);
|
||||
},
|
||||
|
|
|
@ -108,7 +108,6 @@ newUI.renderClass();
|
|||
})();
|
||||
|
||||
msg.onExtension(onRuntimeMessage);
|
||||
window.on('closeOptions', () => router.updateHash(''));
|
||||
|
||||
function onRuntimeMessage(msg) {
|
||||
switch (msg.method) {
|
||||
|
@ -135,6 +134,7 @@ async function toggleEmbeddedOptions(show, el, selector) {
|
|||
if (show) {
|
||||
$.root.appendChild($create('iframe' + selector, {src: '/options.html'}))
|
||||
.focus();
|
||||
await new Promise(resolve => window.on('closeOptions', resolve, {once: true}));
|
||||
} else {
|
||||
el.contentDocument.body.classList.add('scaleout');
|
||||
await animateElement(el, 'fadeout');
|
||||
|
|
Loading…
Reference in New Issue
Block a user