From 7f71fbc3ea8958295f61e9c70542ab9ef5284440 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Thu, 11 Jun 2026 07:35:32 +0900 Subject: [PATCH] Email list: scroll an expanded card into view after click When clicking an email higher up in the list, its top edge can be hiding behind the modal header or off-screen. After applying the .email-card-expanded class + the new minHeight, scrollIntoView(block:start) on the next animation frame so the user sees the whole card. --- static/js/emailLibrary.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index 2e3f844f7..8fda6b898 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -2249,6 +2249,13 @@ async function _toggleCardPreview(card, em) { card.classList.add('email-card-expanded'); card.classList.add('doclib-card-expanded'); card.style.minHeight = `${Math.round(stableOpenHeight)}px`; + // Pull the card into view in case the user clicked an email further up + // the list whose top is partially scrolled off the viewport. Wait for + // the layout to settle (minHeight just changed) before scrolling so + // the browser scrolls toward the post-expansion position. + requestAnimationFrame(() => { + try { card.scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch (_) {} + }); if (!em.is_read) { _syncEmailReadState(em.uid, true); fetch(`${API_BASE}/api/email/mark-read/${em.uid}?folder=${encodeURIComponent(folderAtStart)}${_acct()}`, { method: 'POST' })