From 9afcded6583f5835ae79a07872573ab9d730766e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 25 Sep 2026 12:27:27 +0300 Subject: [PATCH] im-web: open admin confirms in a top-layer dialog position:fixed confirms inside the scrolling users table resolved against that box, so Disable landed off the page. Every admin overlay now opens a popover; the top layer's containing block is the viewport. --- crates/im-web/assets/main.css | 57 +++++++++---------- crates/im-web/src/admin.rs | 102 +++++++++++++++++++++++----------- style/main.scss | 72 +++++++++++------------- 3 files changed, 130 insertions(+), 101 deletions(-) diff --git a/crates/im-web/assets/main.css b/crates/im-web/assets/main.css index 9ab4d1d..deb8413 100644 --- a/crates/im-web/assets/main.css +++ b/crates/im-web/assets/main.css @@ -1135,50 +1135,47 @@ body:has(.log-list) .admin-card:has(.log-list) { background: var(--danger-tint-alt); } -.admin-confirm { - position: relative; - display: inline-flex; +.admin-dialog { + width: min(240px, 100vw - 32px); + height: fit-content; + max-height: min(85vh, 85dvh); + margin: auto; + inset: 0; + padding: 12px; + border: 1px solid var(--border-strong); + border-radius: var(--radius); + background: var(--surface); + color: var(--ink); + box-shadow: var(--shadow-2); + overflow: auto; } -.admin-confirm summary { - list-style: none; - display: inline-flex; - align-items: center; - box-sizing: border-box; +.admin-dialog::backdrop { + background: rgba(0, 0, 0, 0.45); } -.admin-confirm summary::-webkit-details-marker { - display: none; +.admin-dialog .admin-action { + width: 100%; + height: 30px; } -.admin-confirm[open] summary { - background: var(--panel-sunken); + +.admin-dialog-wide { + width: min(420px, 100vw - 32px); } -.admin-confirm-pop { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - z-index: 30; - width: 240px; - padding: 12px; - background: var(--surface); - border: 1px solid var(--border-strong); - border-radius: var(--radius); - box-shadow: var(--shadow-2); +.admin-dialog:popover-open { display: flex; flex-direction: column; gap: 8px; - font-size: 12px; -} -.admin-confirm-pop .admin-action { - width: 100%; - height: 30px; } -.admin-confirm-title { +.admin-dialog-title { font-weight: 600; color: var(--ink); } +.admin-action:has(+ .admin-dialog:popover-open) { + background: var(--panel-sunken); +} + .admin-sessions { display: inline-block; vertical-align: top; diff --git a/crates/im-web/src/admin.rs b/crates/im-web/src/admin.rs index 22ebe89..cdf3c9e 100644 --- a/crates/im-web/src/admin.rs +++ b/crates/im-web/src/admin.rs @@ -51,11 +51,50 @@ fn escape(raw: &str) -> String { .replace('\'', "'") } -/// One row action as a two-step disclosure — iz's `confirm-details` idiom: -/// the summary is the word ("Delete"), the opened panel says what it costs -/// and holds the button that actually does it. The eight `&str`s travel as +/// One admin overlay. The panel is a top-layer popover, not a positioned +/// descendant of the row. `position: fixed` inside `.admin-table-wrap` (a +/// scroll container) or a table cell resolves `top`/`left` against that box +/// as soon as an ancestor creates a containing block — a transform, a +/// filter, or the table itself in some engines — so a "centered" confirm +/// lands off the page. The top layer's containing block is the viewport. +/// Every admin overlay goes through [`admin_dialog`]. Do not emit a +/// positioned panel inside a row. +struct AdminDialog<'a> { + id: &'a str, + word: &'a str, + extra_class: &'a str, + title: &'a str, + body: &'a str, + wide: bool, +} + +/// Stable, attribute-safe id. The field value may be escaped HTML; the +/// popover id must not be, and two different values must not collide. +fn dialog_id(action: &str, field: &str, id: &str) -> String { + let raw = format!("{action}\0{field}\0{id}"); + let hash = raw.bytes().fold(0xcbf29ce484222325u64, |hash, byte| { + (hash ^ u64::from(byte)).wrapping_mul(0x100000001b3) + }); + format!("d{hash:x}") +} + +fn admin_dialog(ask: AdminDialog<'_>) -> String { + let wide = if ask.wide { " admin-dialog-wide" } else { "" }; + format!( + r#"
{title}
{body}
"#, + extra = ask.extra_class, + id = ask.id, + word = ask.word, + title = ask.title, + body = ask.body, + wide = wide, + ) +} + +/// One row action as a two-step confirm. The word opens the dialog; the +/// dialog holds the button that actually posts. Eight `&str`s travel as /// named fields: eight positional parameters tripped the too-many-arguments -/// lint, and the names read better at the call sites anyway. +/// lint. struct ConfirmAction<'a> { field: &'a str, id: &'a str, @@ -77,28 +116,25 @@ fn confirm_action(ask: ConfirmAction<'_>) -> String { cost, confirm, } = ask; - format!( - r#"
{word}
{title}
{cost}
"# - ) + let dialog = dialog_id(action, field, id); + let body = format!( + r#"
{cost}
"# + ); + admin_dialog(AdminDialog { + id: &dialog, + word, + extra_class, + title, + body: &body, + wide: false, + }) } -/// The panel's live wiring moved into the shell: `layout::live_script` runs -/// on every signed-in page and morphs through `__imRefresh`. What stays here -/// is the one bit of behavior the no-script markup cannot do itself — an open -/// confirm disclosure closes on outside click and Escape. +/// Outside-click and Escape on a confirm are the popover's own light +/// dismiss — no script. What stays here is the one bit the markup cannot do +/// itself: the show-once banner's copy button. const ADMIN_SCRIPT: &str = r#"