From 606daa5ed86deff41e7a1702390f0a8ef1ccaef7 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Sat, 1 Aug 2026 15:13:41 +0200 Subject: [PATCH] fix(timeline): clear stale jump to latest state --- src/app/features/room/RoomTimeline.test.tsx | 19 +++++++++++++++++++ src/app/features/room/RoomTimeline.tsx | 1 + 2 files changed, 20 insertions(+) diff --git a/src/app/features/room/RoomTimeline.test.tsx b/src/app/features/room/RoomTimeline.test.tsx index 8aaa67d79..e341644b9 100644 --- a/src/app/features/room/RoomTimeline.test.tsx +++ b/src/app/features/room/RoomTimeline.test.tsx @@ -548,6 +548,25 @@ describe('unread read marker (sliding sync)', () => { }); describe('scroll-edge pagination', () => { + it('marks the timeline as at the bottom when jumping to latest', async () => { + const { getByText, queryByText } = renderTimeline(); + + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 150)); + }); + + // Simulate a stale virtualizer measurement reporting the viewport above the + // bottom. A programmatic jump may not emit a follow-up scroll event. + act(() => lastOnScroll?.(0)); + expect(getByText('Jump to Latest')).toBeTruthy(); + + act(() => { + getByText('Jump to Latest').click(); + }); + + expect(queryByText('Jump to Latest')).toBeNull(); + }); + it('paginates backwards near the top only while a pagination token exists', () => { const { rerender } = renderTimeline(); diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 327e51505..378d2fb73 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -1331,6 +1331,7 @@ export function RoomTimeline({ onClick={() => { if (eventId) navigateRoom(room.roomId, undefined, { replace: true }); timelineSync.setTimeline(getInitialTimeline(room)); + setAtBottom(true); scrollToBottom(); }} style={{