Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): complete thread position restore only against the switched thread's rows #12222

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/12222/headopened View on GitHub

Showing 2 changed files with 160 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
160 additions and 0 deletionsapps/web/src/components/chat/MessagesTimeline.test.tsxModified
View file
@@ -12,6 +12,7 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from "vite-plus/test";
import type { LegendListRef, MaintainScrollAtEndOptions } from "@legendapp/list/react";
import { shouldUseRestingComposerLayout } from "../composerFooterLayout";
+import { rememberTimelinePosition } from "./timelineScrollAnchoring";
import { useComposerFocusState } from "./useComposerFocusState";
​
vi.mock("@legendapp/list/react", async () => {
@@ -1067,6 +1068,165 @@
+ it("waits for the saved anchor's rows during a position restore, then falls back at its deadline", async () => {
+ vi.useFakeTimers();
+ const frames = new Map<number, FrameRequestCallback>();
+ vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
+ const frame = frames.size + 1;
+ frames.set(frame, callback);
+ return frame;
+ });
+ vi.stubGlobal("cancelAnimationFrame", (frame: number) => frames.delete(frame));
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ const createListRef = (calls: {
+ scrollToIndex: ReturnType<typeof vi.fn>;
+ scrollToOffset: ReturnType<typeof vi.fn>;
+ scrollToEnd: ReturnType<typeof vi.fn>;
+ }) => {
+ const ref = createRef<LegendListRef | null>();
+ ref.current = {