selection fix
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user