selection fix

This commit is contained in:
2025-11-11 21:50:08 +01:00
parent 8e7a2f3d6c
commit 1111784caa
4 changed files with 29 additions and 26 deletions
@@ -59,6 +59,34 @@ const DocumentsPanel = ({
const showingSearchResults = searchResults !== null;
const rows = showingSearchResults ? searchResults : documents;
const currentFolderId = useMemo(() => {
if (showingSearchResults) {
return null;
}
const trail = Array.isArray(breadcrumbs) ? breadcrumbs : [];
if (trail.length === 0) {
return 'root';
}
return trail[trail.length - 1]?.id || 'root';
}, [breadcrumbs, showingSearchResults]);
const selectionContextRef = useRef(null);
useEffect(() => {
const nextContext = showingSearchResults
? { type: 'search', marker: searchResults }
: { type: 'folder', marker: currentFolderId || 'root' };
const previous = selectionContextRef.current;
selectionContextRef.current = nextContext;
if (!previous) {
return;
}
const changed = previous.type !== nextContext.type
|| previous.marker !== nextContext.marker;
if (changed) {
onClearSelection?.();
}
}, [showingSearchResults, currentFolderId, searchResults, onClearSelection]);
const entries = useMemo(() => {
const list = [];
if (!showingSearchResults) {