Skip to content

Commit a1950fd

Browse files
authored
Fix row pinning effect so it always runs (#2022)
The old effect wasn't running on every data change, since it depended on table, which is a ref. Now, it will always run on any data change and as a Layout Effect so it will run before paint.
1 parent d469432 commit a1950fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

frontend/app/view/preview/directorypreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import clsx from "clsx";
2929
import dayjs from "dayjs";
3030
import { PrimitiveAtom, atom, useAtom, useAtomValue, useSetAtom } from "jotai";
3131
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
32-
import React, { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
32+
import React, { Fragment, memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3333
import { useDrag, useDrop } from "react-dnd";
3434
import { quote as shellQuote } from "shell-quote";
3535
import { debounce } from "throttle-debounce";
@@ -383,15 +383,15 @@ function DirectoryTable({
383383
setSelectedPath((allRows[focusIndex]?.getValue("path") as string) ?? null);
384384
}, [table, focusIndex, data]);
385385

386-
useEffect(() => {
386+
useLayoutEffect(() => {
387387
const rows = table.getRowModel()?.flatRows;
388388
for (const row of rows) {
389389
if (row.getValue("name") == "..") {
390390
row.pin("top");
391391
return;
392392
}
393393
}
394-
}, [table]);
394+
}, [table, data]);
395395
const columnSizeVars = useMemo(() => {
396396
const headers = table.getFlatHeaders();
397397
const colSizes: { [key: string]: number } = {};

0 commit comments

Comments
 (0)