fix(list): stop the batch toolbar hiding the message you just selected

Opening the toolbar feeds its height back into scrollTop so rows keep
their position on screen. At the top of the list there are no rows above
to hold steady, so that scroll instead slides the first message under the
toolbar — select the top message and it disappears behind the bar acting
on it.

Skip the compensation when the list is already at the top and let the
content move down there, which is what the toolbar taking up space
should do. Mid-list behaviour is unchanged, and the scroll is clamped at
zero so collapsing the toolbar cannot drive it negative.
This commit is contained in:
Shuki Vaknin
2026-09-01 19:05:35 +03:00
parent a210b22e49
commit 71dd5f4fed
+7 -1
View File
@@ -156,6 +156,11 @@ export function EmailList({
// open it shrinks the list and would shove every row downwards. Feed each
// height change back into scrollTop so the rows stay put on screen (and
// slide back when the toolbar collapses again).
//
// Except at the very top: there are no rows above to hold steady, so the
// compensation just scrolls the first message underneath the toolbar and
// reads as the toolbar covering the message you selected. Let the list
// move down there instead.
useEffect(() => {
const toolbar = batchToolbarRef.current;
if (!toolbar || typeof ResizeObserver === 'undefined') return;
@@ -166,7 +171,8 @@ export function EmailList({
lastHeight = height;
const list = parentRef.current;
if (!list || delta === 0) return;
list.scrollTop += delta;
if (delta > 0 && list.scrollTop <= 0) return;
list.scrollTop = Math.max(0, list.scrollTop + delta);
});
observer.observe(toolbar);
return () => observer.disconnect();