Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): settle the measured end when a thread first opens #26028

Closeddiddletime(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/26028/headopened View on GitHub

Showing 3 changed files with 46 additions and 5 deletions.

x
0 of 3 viewed, 3 left
1 addition and 3 deletionsapps/web/src/components/chat/MessagesTimeline.tsxModified
View file
@@ -399,9 +399,7 @@
// A list that opens on a thread with find open takes the opening step below,
// so the restore runs and releases follow once for find.
- const [positionedThreadKey, setPositionedThreadKey] = useState<string | null>(() =>
- listState.rememberedPosition?.atEnd === false || findOpen ? null : listIdentityKey,
- );
+ const [positionedThreadKey, setPositionedThreadKey] = useState<string | null>(null);
const restoringThreadPosition = positionedThreadKey !== listIdentityKey;
const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
const [settlingListIdentity, setSettlingListIdentity] = useState<string | null>(listIdentityKey);
44 additions and 1 deletionapps/web/src/components/chat/useTimelinePositionRestore.test.tsModified
View file
@@ -1,5 +1,48 @@
import { describe, expect, it, vi } from "vite-plus/test";
-import { measuredEndOffset, settleListScroll } from "./useTimelinePositionRestore";
+import {
+ measuredEndOffset,
+ settleListScroll,
+ startTimelinePositionRestore,
+} from "./useTimelinePositionRestore";
+import type { LegendListRef } from "@legendapp/list/react";
+import type { TimelineViewport } from "./timelineViewport";
+​
+it("corrects the measured end on the list's first opening", async () => {
+ vi.useFakeTimers();
+ vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) =>
+ setTimeout(() => callback(0), 16),
+ );