Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): preserve Agents panel scroll position #9637

Closedf4llenz(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/9637/headopened View on GitHub

Showing 6 changed files with 56 additions and 0 deletions (loading 4).

x
0 of 6 viewed, 6 left
52 additions and 0 deletionsapps/web/src/components/ui/scroll-area.test.tsxAdded
View file
@@ -0,0 +1,52 @@
+import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from "react";
+import { act, createRef } from "react";
+import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+​
+import { installReactTestDom } from "~/test/reactTestDom";
+​
+vi.mock("@base-ui/react/scroll-area", () => ({
+ ScrollArea: {
+ Root: forwardRef<HTMLDivElement, ComponentPropsWithoutRef<"div">>((props, ref) => (
+ <div ref={ref} data-primitive="root" {...props} />
+ )),
+ Viewport: forwardRef<HTMLDivElement, ComponentPropsWithoutRef<"div">>((props, ref) => (
+ <div ref={ref} data-primitive="viewport" {...props} />
+ )),
+ Scrollbar: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Thumb: () => <div />,
+ Corner: () => <div />,
+ },
+}));
+​
+import { ScrollArea } from "./scroll-area";
+​
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+​
+describe("ScrollArea refs", () => {
+ it("keeps the root ref on the root and sends viewportRef to the scrolling viewport", async () => {
+ const document = installReactTestDom();
+ const container = document.createElement("div");