From a595a145f0e3fef0e0e28ddb3bccdc05e3221078 Mon Sep 17 00:00:00 2001 From: Saul-Mirone Date: Thu, 26 Dec 2024 02:41:09 +0000 Subject: [PATCH] fix(editor): should remove drag preview after drop (#9313) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: [BS-2219](https://linear.app/affine-design/issue/BS-2219/拖拽后,原编辑器内容有残留) --- .../drag-handle/watchers/drag-event-watcher.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/blocksuite/blocks/src/root-block/widgets/drag-handle/watchers/drag-event-watcher.ts b/blocksuite/blocks/src/root-block/widgets/drag-handle/watchers/drag-event-watcher.ts index 128b1f8cdc..0923efe2ce 100644 --- a/blocksuite/blocks/src/root-block/widgets/drag-handle/watchers/drag-event-watcher.ts +++ b/blocksuite/blocks/src/root-block/widgets/drag-handle/watchers/drag-event-watcher.ts @@ -72,9 +72,15 @@ export class DragEventWatcher { } }; - private readonly _dragEndHandler: UIEventHandler = () => { + private readonly _cleanup = () => { + this.widget.previewHelper.removeDragPreview(); this.widget.clearRaf(); this.widget.hide(true); + this._std.selection.setGroup('gfx', []); + }; + + private readonly _dragEndHandler: UIEventHandler = () => { + this._cleanup(); }; private readonly _dragMoveHandler: UIEventHandler = ctx => { @@ -118,9 +124,7 @@ export class DragEventWatcher { return; } this._onDrop(context); - this._std.selection.setGroup('gfx', []); - this.widget.clearRaf(); - this.widget.hide(true); + this._cleanup(); }; private readonly _onDragMove = (state: DndEventState) => {