From d28fea9fc08bb61e8e989761cad94ebde0b354dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 16:52:01 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(web):=20escape=20stops=20can?= =?UTF-8?q?celling=20its=20own=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A real Escape carries a browser default — stop loading — that killed the navigation the keydown handler had just started, latching __izlekLeaving true and deadening every later press. Synthetic test keys carry no default, which is why only a live keyboard ever showed it. Every ESC branch that navigates now calls preventDefault() first: viewer, delete confirm, task modal, rules edit row. Reproduced and verified on real flatpak Chromium under the nested-sway harness: modal → board, viewer → task → board, ESC mid-playback. --- crates/izlek-web/src/detail.rs | 15 +++++++++++---- crates/izlek-web/src/layout.rs | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index 7d6ceaf..16022f7 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -685,7 +685,12 @@ async fn avatar(cx: &Cx, person: &Person, extra: &str) -> Result { /// `__izlekLeaving` is one navigation per document, `pageshow` releases it. /// Focused native media controls swallow `Escape` before the page ever /// sees the key, so focus landing on the viewer's audio/video is moved -/// straight back to the panel. +/// straight back to the panel. Every branch that navigates must +/// `preventDefault()` first: a real Escape's browser default is +/// stop-loading, which cancels the navigation the handler just started +/// (and would leave `__izlekLeaving` latched true, deadening every +/// later press). Synthetic keys carry no default, so only a live +/// keyboard ever showed it. async fn escape_closes(cx: &Cx) -> Result { use topcoat::view::Unescaped; const JS: &str = "\ @@ -694,12 +699,14 @@ async fn escape_closes(cx: &Cx) -> Result { if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return; } \ var viewer = document.querySelector('.viewer-scrim'); \ if (viewer) { \ + e.preventDefault(); \ if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = viewer.querySelector('.viewer-close').getAttribute('href'); } \ e.stopImmediatePropagation(); \ return; \ } \ var confirm = document.querySelector('details.confirm-details[open]'); \ if (confirm && window.location.search.indexOf('confirm=delete') !== -1) { \ + e.preventDefault(); \ if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = '/'; } \ e.stopImmediatePropagation(); \ return; \ @@ -715,9 +722,9 @@ async fn escape_closes(cx: &Cx) -> Result { e.stopImmediatePropagation(); \ return; \ } \ - if (document.querySelector('.modal-scrim') && !window.__izlekLeaving) { \ - window.__izlekLeaving = true; \ - window.location.href = '/'; \ + if (document.querySelector('.modal-scrim')) { \ + e.preventDefault(); \ + if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = '/'; } \ e.stopImmediatePropagation(); \ } \ }, true); \ diff --git a/crates/izlek-web/src/layout.rs b/crates/izlek-web/src/layout.rs index f79dc11..e850cf3 100644 --- a/crates/izlek-web/src/layout.rs +++ b/crates/izlek-web/src/layout.rs @@ -69,6 +69,7 @@ pub async fn escape_script(cx: &Cx) -> Result { var composer = document.querySelector('details.rule-new[open]'); \ if (composer) { composer.removeAttribute('open'); e.stopImmediatePropagation(); return; } \ if (document.querySelector('.rule-new-body[action=\"/api/update_rule\"]')) { \ + e.preventDefault(); \ window.location.href = '/rules'; \ e.stopImmediatePropagation(); \ } \