From de8c20af638078a4e4967b2529cb1c346350118e Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 8 Mar 2026 17:21:02 -0500 Subject: [PATCH 1/3] fix scroll clamping to bottom of timeline --- src/app/features/room/RoomTimeline.tsx | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 51e155a5..350f7adf 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -917,33 +917,26 @@ export function RoomTimeline({ } }, [mx, room, hideReads]); - const debounceSetAtBottom = useDebounce( - useCallback( - (entry: IntersectionObserverEntry) => { - if (!entry.isIntersecting) setAtBottom(false); - }, - [setAtBottom] - ), - { wait: 1000 } - ); - useIntersectionObserver( useCallback( (entries) => { const target = atBottomAnchorRef.current; if (!target) return; const targetEntry = getIntersectionObserverEntry(target, entries); - if (targetEntry) debounceSetAtBottom(targetEntry); - if (targetEntry?.isIntersecting) { - // Track scroll position independently of atLiveEndRef so that atBottom - // is always accurate. tryAutoMarkAsRead still requires atLiveEndRef. + if (!targetEntry) return; + + if (targetEntry.isIntersecting) { + // User has reached the bottom setAtBottom(true); if (atLiveEndRef.current && document.hasFocus()) { tryAutoMarkAsRead(); } + } else { + // User has intentionally scrolled up. + setAtBottom(false); } }, - [debounceSetAtBottom, tryAutoMarkAsRead, setAtBottom] + [tryAutoMarkAsRead, setAtBottom] ), useCallback( () => ({ From 8219fab32f26729e64063be39b3efd3fc2a8be6b Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 8 Mar 2026 17:23:43 -0500 Subject: [PATCH 2/3] unused import --- src/app/features/room/RoomTimeline.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 350f7adf..c6736e27 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -103,7 +103,6 @@ import { useIntersectionObserver, } from '$hooks/useIntersectionObserver'; import { markAsRead } from '$utils/notifications'; -import { useDebounce } from '$hooks/useDebounce'; import { getResizeObserverEntry, useResizeObserver } from '$hooks/useResizeObserver'; import { inSameDay, minuteDifference, timeDayMonthYear, today, yesterday } from '$utils/time'; import { createMentionElement, isEmptyEditor, moveCursor } from '$components/editor'; From 098caada938a98848056bd8accf5e65360e1ce75 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 8 Mar 2026 17:26:09 -0500 Subject: [PATCH 3/3] changeset --- .changeset/a_fix_scroll_behaviour.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/a_fix_scroll_behaviour.md diff --git a/.changeset/a_fix_scroll_behaviour.md b/.changeset/a_fix_scroll_behaviour.md new file mode 100644 index 00000000..b652cb64 --- /dev/null +++ b/.changeset/a_fix_scroll_behaviour.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Fix scroll clamping to bottom while scrolling up.