Skip to content

Commit 252f5b3

Browse files
committed
Fix for janky scrolling on the run page
1 parent 014d233 commit 252f5b3

File tree

2 files changed

+11
-12
lines changed
  • apps/webapp/app
    • components/primitives/TreeView
    • routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam

2 files changed

+11
-12
lines changed

apps/webapp/app/components/primitives/TreeView/TreeView.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type TreeViewProps<TData> = {
1919
nodes: UseTreeStateOutput["nodes"];
2020
autoFocus?: boolean;
2121
virtualizer: Virtualizer<HTMLElement, Element>;
22-
parentRef: MutableRefObject<HTMLElement | null>;
22+
parentRef?: MutableRefObject<HTMLElement | null>;
2323
scrollRef?: MutableRefObject<HTMLElement | null>;
2424
onScroll?: (scrollTop: number) => void;
2525
} & Pick<UseTreeStateOutput, "getTreeProps" | "getNodeProps">;
@@ -42,9 +42,9 @@ export function TreeView<TData>({
4242
}: TreeViewProps<TData>) {
4343
useEffect(() => {
4444
if (autoFocus) {
45-
parentRef.current?.focus();
45+
parentRef?.current?.focus();
4646
}
47-
}, [autoFocus, parentRef.current]);
47+
}, [autoFocus, parentRef?.current]);
4848

4949
const virtualItems = virtualizer.getVirtualItems();
5050

@@ -58,7 +58,7 @@ export function TreeView<TData>({
5858
);
5959

6060
useEffect(() => {
61-
//subscribe to parentRef scroll event
61+
//subscribe to scrollRef scroll event
6262
if (!scrollRef?.current || onScroll === undefined) return;
6363
scrollRef.current.addEventListener("scroll", scrollCallback);
6464
return () => scrollRef.current?.removeEventListener("scroll", scrollCallback);
@@ -67,7 +67,9 @@ export function TreeView<TData>({
6767
return (
6868
<motion.div
6969
ref={(element) => {
70-
parentRef.current = element;
70+
if (parentRef) {
71+
parentRef.current = element;
72+
}
7173
if (scrollRef) {
7274
scrollRef.current = element;
7375
}

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam/route.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ function TasksTreeView({
319319
renderNode={({ node, state }) => (
320320
<div
321321
className={cn(
322-
"flex h-8 cursor-pointer items-center overflow-hidden rounded-l-sm pr-2",
322+
"delay-[25ms] flex h-8 cursor-pointer items-center overflow-hidden rounded-l-sm pr-2 transition-colors",
323323
state.selected
324324
? "bg-grid-dimmed hover:bg-grid-bright"
325325
: "bg-transparent hover:bg-grid-dimmed"
@@ -377,10 +377,7 @@ function TasksTreeView({
377377
)}
378378
onScroll={(scrollTop) => {
379379
//sync the scroll to the tree
380-
if (
381-
timelineScrollRef.current &&
382-
timelineScrollRef.current.scrollTop !== scrollTop
383-
) {
380+
if (timelineScrollRef.current) {
384381
timelineScrollRef.current.scrollTop = scrollTop;
385382
}
386383
}}
@@ -571,7 +568,6 @@ function TimelineView({
571568
/>
572569
)}
573570
<TreeView
574-
parentRef={parentRef}
575571
scrollRef={timelineScrollRef}
576572
virtualizer={virtualizer}
577573
tree={events}
@@ -623,7 +619,7 @@ function TimelineView({
623619
}}
624620
onScroll={(scrollTop) => {
625621
//sync the scroll to the tree
626-
if (treeScrollRef.current && treeScrollRef.current.scrollTop !== scrollTop) {
622+
if (treeScrollRef.current) {
627623
treeScrollRef.current.scrollTop = scrollTop;
628624
}
629625
}}
@@ -643,6 +639,7 @@ function NodeText({ node }: { node: RunEvent }) {
643639
</Paragraph>
644640
);
645641
}
642+
646643
function NodeStatusIcon({ node }: { node: RunEvent }) {
647644
if (node.data.level !== "TRACE") return null;
648645
if (node.data.style.variant !== "primary") return null;

0 commit comments

Comments
 (0)