From 7ebc467184a07fa30d19e54fcb0a304d0d3ef899 Mon Sep 17 00:00:00 2001 From: nikec <43032218+niikeec@users.noreply.github.com> Date: Tue, 18 Apr 2023 08:23:30 +0200 Subject: [PATCH] [ENG-475] Fix list view scroller (#715) Switch to absolute rows --- .../app/$libraryId/Explorer/ListView.tsx | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/interface/app/$libraryId/Explorer/ListView.tsx b/interface/app/$libraryId/Explorer/ListView.tsx index 60eeadd33..fb4fb1803 100644 --- a/interface/app/$libraryId/Explorer/ListView.tsx +++ b/interface/app/$libraryId/Explorer/ListView.tsx @@ -17,7 +17,6 @@ import { useKey, useOnWindowResize } from 'rooks'; import { ExplorerItem, ObjectKind, isObject, isPath } from '@sd/client'; import { getExplorerStore, useExplorerStore } from '~/hooks/useExplorerStore'; import { useScrolled } from '~/hooks/useScrolled'; -import { TOP_BAR_HEIGHT } from '../TopBar'; import RenameTextBox from './File/RenameTextBox'; import Thumb from './File/Thumb'; import { InfoPill } from './Inspector'; @@ -78,7 +77,6 @@ export default () => { ); const paddingX = 16; - const paddingY = 12; const scrollBarWidth = 8; const getObjectData = (data: ExplorerItem) => (isObject(data) ? data.item : data.item.object); @@ -171,26 +169,13 @@ export default () => { const rowVirtualizer = useVirtualizer({ count: rows.length, getScrollElement: () => scrollRef.current, - estimateSize: () => 45 + estimateSize: () => 45, + paddingStart: 12, + paddingEnd: 12 }); const virtualRows = rowVirtualizer.getVirtualItems(); - const paddingTop = virtualRows[0]?.start || paddingY; - const paddingBottom = useMemo(() => { - const scrollHeight = scrollRef.current?.offsetHeight || 0; - const tableHeaderHeight = 34; - const tableEnd = virtualRows[virtualRows.length - 1]?.end || 0; - const padding = - scrollHeight - - TOP_BAR_HEIGHT - - tableHeaderHeight - - paddingY - - tableEnd - - scrollBarWidth; - return padding > 0 ? padding : paddingY; - }, [virtualRows]); - function handleResize() { if (scrollRef.current) { if (locked && Object.keys(columnSizing).length > 0) { @@ -368,26 +353,38 @@ export default () => {