Skip to content

Commit 76a5a2c

Browse files
author
wwsun
committed
fix: fix render components tree
1 parent 53ebd89 commit 76a5a2c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/core/src/models/workspace.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { action, computed, makeObservable, observable } from 'mobx';
22
import { JSXElement } from '@babel/types';
33
import {
4-
array2object,
54
ComponentPrototypeType,
65
hasFileExtension,
76
isString,
@@ -16,7 +15,6 @@ import {
1615
getJSXElementChildrenNames,
1716
namesToImportDeclarations,
1817
getBlockNameByFilename,
19-
getPrivilegeCode,
2018
prototype2importDeclarationData,
2119
} from '../helpers';
2220
import { DropMethod } from './drop-target';

packages/designer/src/sidebar/outline-panel/components-tree.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ export const ComponentsTree: React.FC<ComponentsTreeProps> = observer(
148148
setSelectedKeys(workspace.selectSource.selected.map((item) => item.id));
149149
}, [workspace.selectSource.selected]);
150150

151+
useEffect(() => {
152+
setExpandedKeys(getNodeKeys(nodesTree));
153+
// nodeTree 更新后重新计算expandKeys
154+
// eslint-disable-next-line react-hooks/exhaustive-deps
155+
}, [nodesTree?.[0]?.id]);
156+
151157
if (!nodesTree.length) {
152158
return (
153159
<Box>
@@ -156,12 +162,6 @@ export const ComponentsTree: React.FC<ComponentsTreeProps> = observer(
156162
);
157163
}
158164

159-
useEffect(() => {
160-
setExpandedKeys(getNodeKeys(nodesTree));
161-
// nodeTree 更新后重新计算expandKeys
162-
// eslint-disable-next-line react-hooks/exhaustive-deps
163-
}, [nodesTree?.[0]?.id]);
164-
165165
return (
166166
<Box css={outlineStyle}>
167167
<Tree
@@ -230,4 +230,4 @@ export const ComponentsTree: React.FC<ComponentsTreeProps> = observer(
230230
</Box>
231231
);
232232
},
233-
);
233+
);

0 commit comments

Comments
 (0)