diff --git a/frontend/app/view/preview/preview-directory.tsx b/frontend/app/view/preview/preview-directory.tsx index 87f358084e..41765662d7 100644 --- a/frontend/app/view/preview/preview-directory.tsx +++ b/frontend/app/view/preview/preview-directory.tsx @@ -25,7 +25,7 @@ import { import clsx from "clsx"; import { PrimitiveAtom, atom, useAtom, useAtomValue, useSetAtom } from "jotai"; import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react"; -import React, { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; +import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useDrag, useDrop } from "react-dnd"; import { quote as shellQuote } from "shell-quote"; import { debounce } from "throttle-debounce"; @@ -225,10 +225,6 @@ function DirectoryTable({ columnVisibility: { path: false, }, - rowPinning: { - top: [], - bottom: [], - }, }, enableMultiSort: false, enableSortingRemoval: false, @@ -240,29 +236,10 @@ function DirectoryTable({ }); useEffect(() => { - const topRows = table.getTopRows() || []; - const centerRows = table.getCenterRows() || []; - const allRows = [...topRows, ...centerRows]; + const allRows = table.getRowModel()?.flatRows || []; setSelectedPath((allRows[focusIndex]?.getValue("path") as string) ?? null); }, [table, focusIndex, data]); - useLayoutEffect(() => { - const rows = table.getRowModel()?.flatRows; - let foundParentDir = false; - - for (const row of rows) { - if (row.getValue("name") == "..") { - row.pin("top"); - foundParentDir = true; - break; - } - } - - // If we didn't find the ".." row, reset the pinning to avoid stale references - if (!foundParentDir) { - table.resetRowPinning(); - } - }, [table, data]); const columnSizeVars = useMemo(() => { const headers = table.getFlatHeaders(); const colSizes: { [key: string]: number } = {}; @@ -447,6 +424,10 @@ function TableBody({ [setRefreshVersion, conn] ); + const allRows = table.getRowModel().flatRows; + const dotdotRow = allRows.find((row) => row.getValue("name") === ".."); + const otherRows = allRows.filter((row) => row.getValue("name") !== ".."); + return (