Skip to content

Commit

Permalink
fix: the dnd node of the card toolbar is not destroyed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
big-camel committed Nov 13, 2022
1 parent b7570cc commit 76fb400
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/engine/src/card/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CardToolbar implements CardToolbarInterface {
private editor: EditorInterface;
private offset?: Array<number>;
private position: Position;
private dndPosition: Position;
#hideTimeout: NodeJS.Timeout | null = null;
#showTimeout: NodeJS.Timeout | null = null;
#defaultAlign: keyof typeof placements = 'topLeft';
Expand All @@ -45,6 +46,7 @@ class CardToolbar implements CardToolbarInterface {
this.editor = editor;
this.card = card;
this.position = new Position(editor);
this.dndPosition = new Position(editor);
this.unbindEnterShow();
if (!isEngine(editor) || editor.readonly) {
this.bindEnterShow();
Expand Down Expand Up @@ -267,6 +269,7 @@ class CardToolbar implements CardToolbarInterface {

hide() {
this.#dndNode?.remove();
this.dndPosition.destroy();
this.hideCardToolbar();
}

Expand All @@ -286,7 +289,7 @@ class CardToolbar implements CardToolbarInterface {
if (this.#dndNode.length > 0) {
this.#dndNode.addClass('data-card-dnd-active');
setTimeout(() => {
this.position.bind(
this.dndPosition.bind(
this.#dndNode!,
this.card.root,
'leftTop',
Expand Down Expand Up @@ -381,6 +384,7 @@ class CardToolbar implements CardToolbarInterface {

destroy() {
this.unbindEnterShow();
this.dndPosition.destroy();
this.position.destroy();
}
}
Expand Down

0 comments on commit 76fb400

Please sign in to comment.