diff --git a/src/app/features/room/RoomTimeline.test.tsx b/src/app/features/room/RoomTimeline.test.tsx index 988b7e166..2e3d49b90 100644 --- a/src/app/features/room/RoomTimeline.test.tsx +++ b/src/app/features/room/RoomTimeline.test.tsx @@ -439,6 +439,22 @@ describe('RoomTimeline content ResizeObserver', () => { ); }); + it('re-pins to the bottom when the timeline viewport shrinks while pinned and live', async () => { + const { container } = renderTimeline(); + + await settleInitialScroll(); + vListHandle.scrollToIndex.mockClear(); + + const timeline = container.querySelector('[data-testid="timeline"]'); + expect(timeline).toBeTruthy(); + act(() => fireResize(timeline!)); + + expect(vListHandle.scrollToIndex).toHaveBeenCalledWith( + 0, + expect.objectContaining({ align: 'end' }) + ); + }); + it('does not re-pin on content growth after scrolling off the bottom', async () => { const { container } = renderTimeline(); diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 8a85f65cf..477b5f5d7 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -953,6 +953,7 @@ export function RoomTimeline({ } const observer = new ResizeObserver(() => { + if (scrollOwnerRef.current === 'live' && atBottomRef.current) scrollToBottom(); syncAtBottom(); });