diff --git a/components/email/email-list.tsx b/components/email/email-list.tsx index 1d82a21ce..a3c12c4d9 100644 --- a/components/email/email-list.tsx +++ b/components/email/email-list.tsx @@ -151,6 +151,26 @@ export function EmailList({ const [isProcessing, setIsProcessing] = useState(false); const parentRef = useRef(null); + const batchToolbarRef = useRef(null); + // The batch toolbar sits above the scroll container, so as it animates + // 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). + useEffect(() => { + const toolbar = batchToolbarRef.current; + if (!toolbar || typeof ResizeObserver === 'undefined') return; + let lastHeight = toolbar.getBoundingClientRect().height; + const observer = new ResizeObserver((entries) => { + const height = entries[0]?.contentRect.height ?? toolbar.getBoundingClientRect().height; + const delta = height - lastHeight; + lastHeight = height; + const list = parentRef.current; + if (!list || delta === 0) return; + list.scrollTop += delta; + }); + observer.observe(toolbar); + return () => observer.disconnect(); + }, []); // One tag treatment for the whole list, measured from the scroll container. const tagDisplay = useMeasuredTagDisplay(parentRef); const density = useSettingsStore((state) => state.density); @@ -353,6 +373,7 @@ export function EmailList({
{/* Batch Actions Toolbar */}