diff --git a/js/router.js b/js/router.js index 1fd3d7dc..76aa4c70 100644 --- a/js/router.js +++ b/js/router.js @@ -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); }, diff --git a/manage/manage.js b/manage/manage.js index 90003b42..fcf9e3c2 100644 --- a/manage/manage.js +++ b/manage/manage.js @@ -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');