Skip to content

Commit 4f01c99

Browse files
authored
fix: focus after drag and deleting comments (#9074)
* fix: focus after drag and deleting comments * chore: fix import
1 parent 53d7876 commit 4f01c99

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

core/block_svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ export class BlockSvg
856856
if (parent) {
857857
focusManager.focusNode(parent);
858858
} else {
859-
focusManager.focusTree(this.workspace);
859+
setTimeout(() => focusManager.focusTree(this.workspace), 0);
860860
}
861861
}
862862

core/comments/rendered_workspace_comment.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {IContextMenu} from '../interfaces/i_contextmenu.js';
1919
import {ICopyable} from '../interfaces/i_copyable.js';
2020
import {IDeletable} from '../interfaces/i_deletable.js';
2121
import {IDraggable} from '../interfaces/i_draggable.js';
22+
import {IFocusableNode} from '../interfaces/i_focusable_node.js';
2223
import type {IFocusableTree} from '../interfaces/i_focusable_tree.js';
2324
import {IRenderedElement} from '../interfaces/i_rendered_element.js';
2425
import {ISelectable} from '../interfaces/i_selectable.js';
@@ -42,7 +43,8 @@ export class RenderedWorkspaceComment
4243
ISelectable,
4344
IDeletable,
4445
ICopyable<WorkspaceCommentCopyData>,
45-
IContextMenu
46+
IContextMenu,
47+
IFocusableNode
4648
{
4749
/** The class encompassing the svg elements making up the workspace comment. */
4850
private view: CommentView;
@@ -207,7 +209,12 @@ export class RenderedWorkspaceComment
207209
/** Disposes of the view. */
208210
override dispose() {
209211
this.disposing = true;
212+
const focusManager = getFocusManager();
213+
if (focusManager.getFocusedNode() === this) {
214+
setTimeout(() => focusManager.focusTree(this.workspace), 0);
215+
}
210216
if (!this.view.isDeadOrDying()) this.view.dispose();
217+
211218
super.dispose();
212219
}
213220

0 commit comments

Comments
 (0)