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.
This commit is contained in:
Evan Simkowitz 2025-02-21 16:57:29 -08:00 committed by GitHub
parent d469432b75
commit a1950fd6f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,7 +29,7 @@ import clsx from "clsx";
import dayjs from "dayjs";
import { PrimitiveAtom, atom, useAtom, useAtomValue, useSetAtom } from "jotai";
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
import React, { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import React, { Fragment, memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useDrag, useDrop } from "react-dnd";
import { quote as shellQuote } from "shell-quote";
import { debounce } from "throttle-debounce";
@ -383,7 +383,7 @@ function DirectoryTable({
setSelectedPath((allRows[focusIndex]?.getValue("path") as string) ?? null);
}, [table, focusIndex, data]);
useEffect(() => {
useLayoutEffect(() => {
const rows = table.getRowModel()?.flatRows;
for (const row of rows) {
if (row.getValue("name") == "..") {
@ -391,7 +391,7 @@ function DirectoryTable({
return;
}
}
}, [table]);
}, [table, data]);
const columnSizeVars = useMemo(() => {
const headers = table.getFlatHeaders();
const colSizes: { [key: string]: number } = {};