Skip to content

Commit b343dff

Browse files
Cameron AmerCameron Amer
authored andcommitted
fix: prevent grid upload cards from overlapping files when switching folders
1 parent 83ddd06 commit b343dff

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

app/src/components/desktop/dashboard/FileCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export function FileCard({ file, onDelete, onDownload, onPreview, onShare, isSel
104104
}}
105105
>
106106
<motion.div
107-
layout
108107
draggable={!isFolder}
109108
onDragStart={(e: any) => {
110109
if (onDragStart) onDragStart(file.id);

app/src/components/desktop/dashboard/FileExplorer.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,21 @@ export function FileExplorer({
142142
gridVirtualizer.measure();
143143
}, [rowHeight, gridVirtualizer]);
144144

145-
const listVirtualizer = useVirtualizer({
145+
const listVirtualizer = useVirtualizer({
146146
count: listItems.length,
147147
getScrollElement: () => parentRef.current,
148148
estimateSize: () => 48,
149149
overscan: 5,
150150
});
151151

152+
useEffect(() => {
153+
if (parentRef.current) {
154+
parentRef.current.scrollTop = 0;
155+
}
156+
gridVirtualizer.scrollToOffset(0);
157+
listVirtualizer.scrollToOffset(0);
158+
}, [activeFolderId, gridVirtualizer, listVirtualizer]);
159+
152160
const handleSort = (field: SortField) => {
153161
if (sortField === field) {
154162
setSortDirection(d => d === 'asc' ? 'desc' : 'asc');
@@ -249,6 +257,7 @@ export function FileExplorer({
249257

250258

251259
<div
260+
key={activeFolderId ?? 'root'}
252261
className="relative w-full"
253262
style={{ height: `${gridVirtualizer.getTotalSize()}px` }}
254263
>
@@ -336,6 +345,7 @@ export function FileExplorer({
336345

337346

338347
<div
348+
key={activeFolderId ?? 'root'}
339349
className="relative w-full"
340350
style={{ height: `${listVirtualizer.getTotalSize()}px` }}
341351
>

0 commit comments

Comments
 (0)