From dce3af045a7b5f25c07e563590378a43249c5671 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 21:46:21 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(web):=20one=20dropdown,=20one?= =?UTF-8?q?=20ring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/izlek-web/src/board.rs | 28 ++++++----- crates/izlek-web/src/detail.rs | 45 ++++++++---------- crates/izlek-web/src/dropdown.rs | 19 ++++---- crates/izlek-web/src/layout.rs | 82 ++++++++++++++++++++++++-------- crates/izlek-web/tests/http.rs | 23 +++++---- 5 files changed, 120 insertions(+), 77 deletions(-) diff --git a/crates/izlek-web/src/board.rs b/crates/izlek-web/src/board.rs index ad12115..af4f921 100644 --- a/crates/izlek-web/src/board.rs +++ b/crates/izlek-web/src/board.rs @@ -378,13 +378,12 @@ async fn render_card( /// open; a plain document click closes it again. Rendered once — every /// card's `@contextmenu` calls into this same global, by the menu's id. /// -/// Also holds the board page's own `Escape` listener — now only the -/// datepicker panel and the card menu: viewer, delete confirm, open edit -/// popovers and the modal itself belong to `detail::escape_closes`, which -/// registers first (inline in the modal markup) and stops the key. The -/// topbar `.user-menu` is handled one script earlier, by -/// `layout::escape_script`, registered before this one so its blur wins -/// over anything below. +/// Also registers the board page's own `Escape` resolvers on +/// `window.__izlekEsc`: the datepicker panel (priority 100, above the modal +/// chain — `detail::escape_closes` used to defer to it) and the card menu +/// (priority 10). Viewer, delete confirm, open edit popovers and the modal +/// itself stay `detail::escape_closes`'s at priority 90; the whole order +/// lives in the table on `layout.rs`'s `escape_manager_script`. async fn card_menu_script(cx: &Cx) -> Result { use topcoat::view::Unescaped; const JS: &str = "\ @@ -401,13 +400,18 @@ async fn card_menu_script(cx: &Cx) -> Result { menu.classList.add('card-menu-open'); \ }; \ document.addEventListener('click', closeCardMenus); \ - document.addEventListener('keydown', function (e) { \ - if (e.key !== 'Escape') { return; } \ + window.__izlekEsc.register(100, function () { \ var datepick = document.querySelector('.datepick-pop > .edit-toggle:checked'); \ - if (datepick) { datepick.checked = false; e.stopImmediatePropagation(); return; } \ + if (!datepick) { return false; } \ + datepick.checked = false; \ + return true; \ + }); \ + window.__izlekEsc.register(10, function () { \ var menu = document.querySelector('.card-menu-open'); \ - if (menu) { closeCardMenus(); e.stopImmediatePropagation(); return; } \ - }, true); \ + if (!menu) { return false; } \ + closeCardMenus(); \ + return true; \ + }); \ document.addEventListener('contextmenu', function (e) { \ var card = e.target.closest ? e.target.closest('.card[data-menu-id]') : null; \ if (!card) { return; } \ diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index f28e628..d836772 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -675,38 +675,30 @@ async fn avatar(cx: &Cx, person: &Person, extra: &str) -> Result { /// `Escape` for everything the task modal renders, topmost first: viewer → /// delete confirm (`confirm=delete` in URL) → open edit popovers → modal -/// itself; datepick and card menu stay `board.rs`'s — this capture listener -/// registers first (inline in modal markup) and stops the key. Closing -/// never navigates: `layout.rs`'s `__izlekCloseViewer`/`__izlekCloseModal` -/// drop the overlay's DOM and rewrite the URL, the board underneath is -/// already rendered. 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. Every closing branch -/// still calls `preventDefault()`: a real Escape's browser default is -/// stop-loading (it once cancelled the navigation these branches used to -/// start; synthetic keys carry no default, so only a live keyboard ever -/// showed it). +/// itself — one resolver at priority 90 on `window.__izlekEsc` (table on +/// `layout.rs`'s `escape_manager_script`); an open datepick popover returns +/// false, leaving it to `board.rs`'s priority-100 resolver. Closing never +/// navigates: `layout.rs`'s `__izlekCloseViewer`/`__izlekCloseModal` drop +/// the overlay's DOM and rewrite the URL, the board underneath is already +/// rendered. 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. async fn escape_closes(cx: &Cx) -> Result { use topcoat::view::Unescaped; const JS: &str = "\ (function () { \ if (window.__izlekEscModal) { return; } \ window.__izlekEscModal = true; \ - document.addEventListener('keydown', function (e) { \ - if (e.key !== 'Escape') { return; } \ - if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return; } \ + window.__izlekEsc.register(90, function () { \ + if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \ if (document.querySelector('.viewer-scrim')) { \ - e.preventDefault(); \ window.__izlekCloseViewer(); \ - e.stopImmediatePropagation(); \ - return; \ + return true; \ } \ var confirm = document.querySelector('details.confirm-details[open]'); \ if (confirm && window.location.search.indexOf('confirm=delete') !== -1) { \ - e.preventDefault(); \ window.__izlekCloseModal(); \ - e.stopImmediatePropagation(); \ - return; \ + return true; \ } \ var toggled = false; \ document.querySelectorAll('.edit-toggle:checked').forEach(function (toggle) { \ @@ -716,15 +708,14 @@ async fn escape_closes(cx: &Cx) -> Result { }); \ if (toggled || confirm) { \ if (confirm) { confirm.removeAttribute('open'); } \ - e.stopImmediatePropagation(); \ - return; \ + return true; \ } \ if (document.querySelector('.modal-scrim')) { \ - e.preventDefault(); \ window.__izlekCloseModal(); \ - e.stopImmediatePropagation(); \ + return true; \ } \ - }, true); \ + return false; \ + }); \ document.addEventListener('focusin', function (e) { \ var media = e.target; \ if (media.tagName !== 'AUDIO' && media.tagName !== 'VIDEO') { return; } \ @@ -879,7 +870,9 @@ async fn datepicker_grid(cx: &Cx, name: &str, value: &str, lang: Lang) -> Result /// nav, day pick, Clear/Today, and closes a panel on outside click — /// registered in the capture phase so a stray click never reaches /// `escape_closes`'s confirm-closing listener while a panel is open. -/// `Escape` itself is handled centrally by `board.rs`'s `card_menu_script`. +/// `Escape` closes the panel through the datepick resolver `board.rs`'s +/// `card_menu_script` registers (priority 100 — see the table on +/// `layout.rs`'s `escape_manager_script`). async fn datepicker_script(cx: &Cx, lang: Lang) -> Result { use crate::i18n::datepicker_js_literals; use topcoat::view::Unescaped; diff --git a/crates/izlek-web/src/dropdown.rs b/crates/izlek-web/src/dropdown.rs index 6046b88..2b387a7 100644 --- a/crates/izlek-web/src/dropdown.rs +++ b/crates/izlek-web/src/dropdown.rs @@ -17,12 +17,10 @@ use topcoat::view::{Unescaped, view}; /// Emitted once per page that renders a `