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.
This commit is contained in:
pewdiepie-archdaemon
2026-06-11 07:35:32 +09:00
parent 7017127a11
commit 7f71fbc3ea
+7
View File
@@ -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' })