Skip to content

Commit

Permalink
Merge pull request #9337 from weseek/fix/111603-126863-pagetree-displ…
Browse files Browse the repository at this point in the history
…ay-the-page-that-is-deleted

fix:  Deleted pages appear in the page tree
  • Loading branch information
mergify[bot] authored Nov 22, 2024
2 parents c13c7a9 + 3a71b77 commit 1dab209
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions apps/app/src/client/components/TreeItem/TreeItemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TreeItemLayout: FC<TreeItemLayoutProps> = (props) => {

const { page, children } = itemNode;

const [currentChildren, setCurrentChildren] = useState(children);
const [currentChildren, setCurrentChildren] = useState<ItemNode[]>(children);
const [isOpen, setIsOpen] = useState(_isOpen);

const { data } = useSWRxPageChildren(isOpen ? page._id : null);
Expand Down Expand Up @@ -87,15 +87,6 @@ export const TreeItemLayout: FC<TreeItemLayoutProps> = (props) => {
if (hasChildren()) setIsOpen(true);
}, [hasChildren]);

/*
* Make sure itemNode.children and currentChildren are synced
*/
useEffect(() => {
if (children.length > currentChildren.length) {
setCurrentChildren(children);
}
}, [children, currentChildren.length, targetPathOrId]);

/*
* When swr fetch succeeded
*/
Expand Down

0 comments on commit 1dab209

Please sign in to comment.