From 2ec3083b6fc485666b9af3b98f0bf5027f72aba8 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Thu, 16 Jul 2026 10:03:45 +0200 Subject: [PATCH] fix: re-anchor new messages divider at last read when tabbing out --- src/app/features/room/RoomTimeline.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 6a48ff989..d44751aae 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -830,9 +830,17 @@ export function RoomTimeline({ useDocumentFocusChange( useCallback( (inFocus) => { - if (inFocus && atBottomState) tryAutoMarkAsRead(); + if (inFocus) { + if (atBottomState) tryAutoMarkAsRead(); + return; + } + // Re-anchor the divider at the last read when tabbing out while caught up. + if (atBottomState && timelineSync.liveTimelineLinked) { + readUptoEventIdRef.current = undefined; + setUnreadInfo(undefined); + } }, - [tryAutoMarkAsRead, atBottomState] + [tryAutoMarkAsRead, atBottomState, timelineSync.liveTimelineLinked, setUnreadInfo] ) );