Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: scrolling up during a running thread no longer snaps back to the bottom #5566

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5566/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 5 changed files with 128 additions and 8 deletions (loading 2).

x
0 of 5 viewed, 5 left
69 additions and 2 deletionsapps/mobile/src/features/threads/ThreadFeed.tsxModified
View file
@@ -1335,6 +1335,24 @@
const [viewportHeight, setViewportHeight] = useState(0);
const [disclosureToggleSettling, setDisclosureToggleSettling] = useState(false);
+ // Live-follow latch. LegendList's maintainScrollAtEnd alone re-pins the feed
+ // whenever the viewport drifts back inside its geometric threshold, which
+ // yanked users off history they were reading every time a stream chunk grew
+ // a row. Follow breaks when the user scrolls up and away, and re-arms only
+ // when the list actually returns to the end (or on send / thread switch).
+ const [endFollowEnabled, setEndFollowEnabled] = useState(true);
+ const endFollowEnabledRef = useRef(true);
+ // A "user scroll session" spans from drag start through the end of its
+ // momentum; only motion inside a session can break follow, so MVCP
+ // compensations and programmatic scrolls never strand a follower.
+ const userScrollSessionRef = useRef(false);
+ const setEndFollow = useCallback((enabled: boolean) => {
+ if (endFollowEnabledRef.current === enabled) {
+ return;
+ }
+ endFollowEnabledRef.current = enabled;
+ setEndFollowEnabled(enabled);
+ }, []);
const [interactionState, setInteractionState] = useState<{
readonly copiedRowId: string | null;
readonly expandedWorkGroups: Record<string, boolean>;
@@ -1454,9 +1472,41 @@
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
nearListEnd.value =
contentSize.height - layoutMeasurement.height - contentOffset.y < layoutMeasurement.height;