From cf9768ba96e043f9923a7c899218567dc6646167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=98=8E=E5=8D=8E?= <51693922+WangMingHua111@users.noreply.github.com> Date: Fri, 12 Aug 2022 12:55:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(stage):=20=E4=BF=AE=E5=A4=8D=E9=9D=9E?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E7=8A=B6=E6=80=81=E4=B8=8B=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E9=80=89=E4=B8=AD=E7=BB=84=E4=BB=B6=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E6=99=AE=E9=80=9A=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20(#254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态 * fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态 * fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态 --- packages/stage/src/StageCore.ts | 12 +++++++++--- packages/stage/src/StageMultiDragResize.ts | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/stage/src/StageCore.ts b/packages/stage/src/StageCore.ts index 8227385c..b4a3e4bf 100644 --- a/packages/stage/src/StageCore.ts +++ b/packages/stage/src/StageCore.ts @@ -139,9 +139,15 @@ export default class StageCore extends EventEmitter { setTimeout(() => this.emit('sort', data)); }); - this.multiDr.on('update', (data: UpdateEventData) => { - setTimeout(() => this.emit('update', data)); - }); + this.multiDr + .on('update', (data: UpdateEventData) => { + setTimeout(() => this.emit('update', data)); + }) + .on('select', async (id: Id) => { + const el = await this.getTargetElement(id); + this.select(el); // 选中 + setTimeout(() => this.emit('select', el)); // set node + }); } public getElementsFromPoint(event: MouseEvent) { diff --git a/packages/stage/src/StageMultiDragResize.ts b/packages/stage/src/StageMultiDragResize.ts index dd27e6d9..39c2ccca 100644 --- a/packages/stage/src/StageMultiDragResize.ts +++ b/packages/stage/src/StageMultiDragResize.ts @@ -124,6 +124,13 @@ export default class StageMultiDragResize extends EventEmitter { }) .on('dragGroupEnd', () => { this.update(); + }) + .on('clickGroup', (params) => { + const { inputTarget, targets } = params; + // 如果此时mask不处于多选状态下,且有多个元素被选中,同时点击的元素在选中元素中的其中一项,代表多选态切换为该元素的单选态 + if (!this.mask.isMultiSelectStatus && targets.length > 1 && targets.includes(inputTarget)) { + this.emit('select', inputTarget.id.replace(DRAG_EL_ID_PREFIX, '')); + } }); }