Skip to content

Commit 30686a5

Browse files
rainkeliujuping
authored andcommitted
fix: the selectionDispose function is never executed
1 parent 731dc58 commit 30686a5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

packages/designer/src/designer/designer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export class Designer implements IDesigner {
144144

145145
private oobxList: OffsetObserver[] = [];
146146

147+
private selectionDispose: undefined | (() => void);
148+
147149
@obx.ref private _componentMetasMap = new Map<string, IComponentMeta>();
148150

149151
@obx.ref private _simulatorComponent?: ComponentType<any>;
@@ -265,10 +267,9 @@ export class Designer implements IDesigner {
265267
}
266268

267269
setupSelection = () => {
268-
let selectionDispose: undefined | (() => void);
269-
if (selectionDispose) {
270-
selectionDispose();
271-
selectionDispose = undefined;
270+
if (this.selectionDispose) {
271+
this.selectionDispose();
272+
this.selectionDispose = undefined;
272273
}
273274
const { currentSelection } = this;
274275
// TODO: 避免选中 Page 组件,默认选中第一个子节点;新增规则 或 判断 Live 模式
@@ -284,7 +285,7 @@ export class Designer implements IDesigner {
284285
}
285286
this.postEvent('selection.change', currentSelection);
286287
if (currentSelection) {
287-
selectionDispose = currentSelection.onSelectionChange(() => {
288+
this.selectionDispose = currentSelection.onSelectionChange(() => {
288289
this.postEvent('selection.change', currentSelection);
289290
});
290291
}

0 commit comments

Comments
 (0)