desaturate theme a bit
This commit is contained in:
@@ -796,6 +796,7 @@ const useDocumentsWorkspace = ({
|
||||
setDraggedFolderId,
|
||||
isInvalidFolderDrop,
|
||||
setCreatingFolder,
|
||||
clearSelection,
|
||||
});
|
||||
|
||||
const {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
DEFAULT_FOLDER_NAME,
|
||||
createRootNode,
|
||||
@@ -30,6 +30,8 @@ const useFolderTree = ({
|
||||
const [currentFolder, setCurrentFolder] = useState(null);
|
||||
const [currentSubfolders, setCurrentSubfolders] = useState([]);
|
||||
|
||||
const lastAppliedFolderIdRef = useRef(null);
|
||||
|
||||
const {
|
||||
focusedDocumentId,
|
||||
setFocusedDocumentId,
|
||||
@@ -41,6 +43,9 @@ const useFolderTree = ({
|
||||
|
||||
const applySelectedFolder = useCallback(
|
||||
(folderId, contents) => {
|
||||
const folderChanged = lastAppliedFolderIdRef.current !== folderId;
|
||||
lastAppliedFolderIdRef.current = folderId;
|
||||
|
||||
const subfolders = contents?.subfolders ?? [];
|
||||
const docs = assetManager.hydrateDocuments(contents?.documents ?? []);
|
||||
const folderInfo = contents?.folder ?? null;
|
||||
@@ -63,6 +68,11 @@ const useFolderTree = ({
|
||||
let mergedSelection = [];
|
||||
|
||||
setSelectedEntries((previous) => {
|
||||
if (folderChanged) {
|
||||
nextDocKeys = [];
|
||||
mergedSelection = [];
|
||||
return [];
|
||||
}
|
||||
const previousFolderKeys = previous
|
||||
.filter(isFolderRowKey)
|
||||
.filter((key) => availableFolderKeys.has(key));
|
||||
@@ -72,6 +82,14 @@ const useFolderTree = ({
|
||||
return mergedSelection;
|
||||
});
|
||||
|
||||
if (folderChanged) {
|
||||
setFocusedDocumentId(null);
|
||||
selectionAnchorRef.current = null;
|
||||
selectionOrderRef.current = [];
|
||||
setSelectionOrder([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextFocus = (() => {
|
||||
const currentFocusedKey = resolveDocumentRowKey(focusedDocumentId);
|
||||
if (currentFocusedKey && availableDocKeySet.has(currentFocusedKey)) {
|
||||
|
||||
@@ -28,6 +28,7 @@ const useFolderTreeActions = ({
|
||||
setDraggedFolderId,
|
||||
isInvalidFolderDrop,
|
||||
setCreatingFolder,
|
||||
clearSelection,
|
||||
}) => {
|
||||
const moveFolder = useCallback(
|
||||
async (folderId, targetFolderId) => {
|
||||
@@ -173,6 +174,10 @@ const useFolderTreeActions = ({
|
||||
async (folderId, { replace = false, immediate = false } = {}) => {
|
||||
const targetId = folderId && folderId !== 'root' ? folderId : 'root';
|
||||
|
||||
if (typeof clearSelection === 'function') {
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
await ensureFolderAncestorsLoaded(targetId);
|
||||
expandFolderAncestors(targetId);
|
||||
|
||||
@@ -186,6 +191,7 @@ const useFolderTreeActions = ({
|
||||
navigate(path, { replace });
|
||||
},
|
||||
[
|
||||
clearSelection,
|
||||
ensureFolderAncestorsLoaded,
|
||||
expandFolderAncestors,
|
||||
isFilterActive,
|
||||
|
||||
Reference in New Issue
Block a user