Skip to content

Commit

Permalink
CB-3884 fix: tree empty flickering (#2457)
Browse files Browse the repository at this point in the history
* CB-3884 fix: tree empty flickering

* CB-3884 fix: blink empty folder message in tree

---------

Co-authored-by: Daria Marutkina <[email protected]>
  • Loading branch information
Wroud and dariamarutkina authored Mar 18, 2024
1 parent e78155a commit 4c9a6d2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.treeNodeNestedMessage {
composes: theme-typography--caption from global;
padding: 4px 12px;
padding: 1px 12px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const NavigationNode: NavigationNodeComponent = observer(function Navigat
}

const hasNodes = getComputed(() => !!dndBox.state.context && dndBox.state.canDrop && dndBox.state.isOverCurrent);
const expanded = useDeferredValue(navNode.expanded || externalExpanded);
const expanded = useDeferredValue((navNode.expanded || externalExpanded) && navNode.loaded);

useEffect(
() => () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export const NavigationNodeNested = observer(
children = useDeferredValue(children);
empty = useDeferredValue(empty);

if (empty && !treeContext?.tree.settings?.foldersTree) {
return null;
}

if (nodeId !== undefined && rootFolder) {
return <NavigationNode nodeId={nodeId} path={path} expanded />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function useElementsTree(options: IOptions): IElementsTree {
if (!loaded) {
const node = navNodeInfoResource.get(child);

if (node) {
if (node && expanded && elementsTree.isNodeExpandable(child)) {
await elementsTree.expand(node, false);
}
return;
Expand All @@ -232,6 +232,15 @@ export function useElementsTree(options: IOptions): IElementsTree {
}
}

if (elementsTree.isNodeExpandable(child) && expanded && elementsTree.getNodeChildren(child).length === 0) {
const node = navNodeInfoResource.get(child);

if (node) {
await elementsTree.expand(node, false);
}
return;
}

if (
elementsTree.settings?.foldersTree &&
options.folderExplorer.options.expandFoldersWithSingleElement &&
Expand Down Expand Up @@ -424,7 +433,7 @@ export function useElementsTree(options: IOptions): IElementsTree {
},
isNodeExpandable(nodeId: string): boolean {
if (nodeId === this.root) {
return true;
return false;
}

if (options.expandStateGetters?.length) {
Expand Down

0 comments on commit 4c9a6d2

Please sign in to comment.