fix(editor): 修复先单击选中页面,再进行多选无法选中的问题

This commit is contained in:
parisma 2022-08-08 19:30:53 +08:00 committed by jia000
parent a4dd4eac02
commit 46e0e23785
2 changed files with 8 additions and 4 deletions

View File

@ -180,7 +180,7 @@ export default class StageCore extends EventEmitter {
if (!canSelectByProp) return false; if (!canSelectByProp) return false;
// 多选规则 // 多选规则
if (this.mask.isMultiSelectStatus) { if (this.mask.isMultiSelectStatus) {
return this.multiDr.canSelect(el); return this.multiDr.canSelect(el, stop);
} }
return true; return true;
} }

View File

@ -127,16 +127,20 @@ export default class StageMultiDragResize extends EventEmitter {
}); });
} }
public canSelect(el: HTMLElement): Boolean { public canSelect(el: HTMLElement, stop: () => boolean): Boolean {
// 多选不可以选中magic-ui-page // 多选状态下不可以选中magic-ui-page,并停止继续向上层选中
if (el.className.includes(PAGE_CLASS)) { if (el.className.includes(PAGE_CLASS)) {
this.core.highlightedDom = undefined; this.core.highlightedDom = undefined;
this.core.highlightLayer.clearHighlight(); this.core.highlightLayer.clearHighlight();
stop();
return false; return false;
} }
const currentTargetMode = getMode(el); const currentTargetMode = getMode(el);
let selectedDomMode = ''; let selectedDomMode = '';
if (this.core.selectedDom?.className.includes(PAGE_CLASS)) {
// 先单击选中了页面(magic-ui-page),再按住多选键多选时,任一元素均可选中
return true;
}
if (this.targetList.length === 0 && this.core.selectedDom) { if (this.targetList.length === 0 && this.core.selectedDom) {
// 单选后添加到多选的情况 // 单选后添加到多选的情况
selectedDomMode = getMode(this.core.selectedDom); selectedDomMode = getMode(this.core.selectedDom);