@@ -25,7 +25,7 @@ import {
2525import clsx from "clsx" ;
2626import { PrimitiveAtom , atom , useAtom , useAtomValue , useSetAtom } from "jotai" ;
2727import { OverlayScrollbarsComponent , OverlayScrollbarsComponentRef } from "overlayscrollbars-react" ;
28- import React , { Fragment , useCallback , useEffect , useLayoutEffect , useMemo , useRef , useState } from "react" ;
28+ import React , { Fragment , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
2929import { useDrag , useDrop } from "react-dnd" ;
3030import { quote as shellQuote } from "shell-quote" ;
3131import { debounce } from "throttle-debounce" ;
@@ -225,10 +225,6 @@ function DirectoryTable({
225225 columnVisibility : {
226226 path : false ,
227227 } ,
228- rowPinning : {
229- top : [ ] ,
230- bottom : [ ] ,
231- } ,
232228 } ,
233229 enableMultiSort : false ,
234230 enableSortingRemoval : false ,
@@ -240,29 +236,10 @@ function DirectoryTable({
240236 } ) ;
241237
242238 useEffect ( ( ) => {
243- const topRows = table . getTopRows ( ) || [ ] ;
244- const centerRows = table . getCenterRows ( ) || [ ] ;
245- const allRows = [ ...topRows , ...centerRows ] ;
239+ const allRows = table . getRowModel ( ) ?. flatRows || [ ] ;
246240 setSelectedPath ( ( allRows [ focusIndex ] ?. getValue ( "path" ) as string ) ?? null ) ;
247241 } , [ table , focusIndex , data ] ) ;
248242
249- useLayoutEffect ( ( ) => {
250- const rows = table . getRowModel ( ) ?. flatRows ;
251- let foundParentDir = false ;
252-
253- for ( const row of rows ) {
254- if ( row . getValue ( "name" ) == ".." ) {
255- row . pin ( "top" ) ;
256- foundParentDir = true ;
257- break ;
258- }
259- }
260-
261- // If we didn't find the ".." row, reset the pinning to avoid stale references
262- if ( ! foundParentDir ) {
263- table . resetRowPinning ( ) ;
264- }
265- } , [ table , data ] ) ;
266243 const columnSizeVars = useMemo ( ( ) => {
267244 const headers = table . getFlatHeaders ( ) ;
268245 const colSizes : { [ key : string ] : number } = { } ;
@@ -447,6 +424,10 @@ function TableBody({
447424 [ setRefreshVersion , conn ]
448425 ) ;
449426
427+ const allRows = table . getRowModel ( ) . flatRows ;
428+ const dotdotRow = allRows . find ( ( row ) => row . getValue ( "name" ) === ".." ) ;
429+ const otherRows = allRows . filter ( ( row ) => row . getValue ( "name" ) !== ".." ) ;
430+
450431 return (
451432 < div className = "dir-table-body" ref = { bodyRef } >
452433 { ( searchActive || search !== "" ) && (
@@ -473,28 +454,28 @@ function TableBody({
473454 < div className = "dummy dir-table-body-row" ref = { dummyLineRef } >
474455 < div className = "dir-table-body-cell" > dummy-data</ div >
475456 </ div >
476- { table . getTopRows ( ) . map ( ( row , idx ) => (
457+ { dotdotRow && (
477458 < TableRow
478459 model = { model }
479- row = { row }
460+ row = { dotdotRow }
480461 focusIndex = { focusIndex }
481462 setFocusIndex = { setFocusIndex }
482463 setSearch = { setSearch }
483- idx = { idx }
464+ idx = { 0 }
484465 handleFileContextMenu = { handleFileContextMenu }
485- key = { "top-" + idx }
466+ key = "dotdot"
486467 />
487- ) ) }
488- { table . getCenterRows ( ) . map ( ( row , idx ) => (
468+ ) }
469+ { otherRows . map ( ( row , idx ) => (
489470 < TableRow
490471 model = { model }
491472 row = { row }
492473 focusIndex = { focusIndex }
493474 setFocusIndex = { setFocusIndex }
494475 setSearch = { setSearch }
495- idx = { idx + table . getTopRows ( ) . length }
476+ idx = { dotdotRow ? idx + 1 : idx }
496477 handleFileContextMenu = { handleFileContextMenu }
497- key = { "center" + idx }
478+ key = { idx }
498479 />
499480 ) ) }
500481 </ div >
0 commit comments