From e7f5cb9bee0606250884c6ca5858664c63d19c2b Mon Sep 17 00:00:00 2001 From: EiSiMo Date: Thu, 23 Apr 2026 13:17:04 +0200 Subject: [PATCH] fix(lightbox): keep arrow clicks from leaking to backdrop close, raise controls above image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Logs from the user's last session showed that after walking through all images and trying to go back from the last one, a backdrop click fired (target===overlay) and closed the modal — even though the user believed they clicked the prev arrow. Two reinforcing causes: 1. The image (.lightbox-image) is a sibling AFTER the buttons in the DOM with no z-index, so paint order put the image on top of the absolute-positioned arrows. Where the image's max-width/height box overlapped the arrows, clicks landed on the image instead of the arrow, and clicks in the gap between image and arrow hit the overlay backdrop. 2. Even when an arrow handler did fire, the click bubbled up to the overlay's click handler. While target===overlay was false in that path, the next click sometimes did land on the backdrop, and the close button had the same exposure. Fix: - Stack the controls above the image: image gets z-index:1, every .lightbox button gets z-index:2. - stopPropagation on prev/next/close button clicks AND on the image click — guarantees they can never bubble into the overlay's backdrop-close handler. Backdrop close still works on actual backdrop clicks. - Bump button background to rgba(0,0,0,.55) (was .08 white on dark) so the arrows are clearly visible against the image. Also strip the [lazyflat.lightbox] DEBUG(lightbox) tracer logs and the window.error catch-all — original symptom is fixed and the existing flow is confirmed working in user's logs. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/static/app.css | 9 +++-- web/static/app.js | 91 +++++++--------------------------------------- 2 files changed, 18 insertions(+), 82 deletions(-) diff --git a/web/static/app.css b/web/static/app.css index 3f1367a..2dec58f 100644 --- a/web/static/app.css +++ b/web/static/app.css @@ -142,12 +142,13 @@ body:has(#v_map:checked) .view-map { display: block; } animation: lightbox-fade .15s ease-out; } .lightbox-image { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); - background: #0c1726; } -.lightbox button { background: rgba(255,255,255,.08); color: #fff; border: 0; + background: #0c1726; position: relative; z-index: 1; } +.lightbox button { background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 9999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; - transition: background .15s, transform .05s; padding: 0; } -.lightbox button:hover { background: rgba(255,255,255,.22); } + transition: background .15s, transform .05s; padding: 0; + z-index: 2; } +.lightbox button:hover { background: rgba(0, 0, 0, .8); } .lightbox button:active { transform: scale(.96); } .lightbox-close { position: absolute; top: 1.25rem; right: 1.25rem; width: 2.5rem; height: 2.5rem; } diff --git a/web/static/app.js b/web/static/app.js index 67dbfbe..cc2105d 100644 --- a/web/static/app.js +++ b/web/static/app.js @@ -90,11 +90,6 @@ document.addEventListener("click", (ev) => { .then((html) => { pane.innerHTML = html; pane.dataset.loaded = "1"; - // DEBUG(lightbox): confirm fetched partial actually contains