-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
issue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong
Description
Check for duplicates
- I have searched for similar issues before opening a new one.
Description
When disposing a workspace with a focused block, Blockly will raise the following error:
focus_manager.ts:232
Uncaught Error: Attempted to focus unregistered tree: [object Object].
at FocusManager$$module$build$src$core$focus_manager.focusTree (focus_manager.ts:232:1)
at eval (block_svg.ts:885:1)
I think it is caused by the following code in core/block_svg.ts:
override dispose(healStack?: boolean, animate?: boolean) {
// ...
const focusManager = getFocusManager();
if (
this.getSvgRoot().contains(
focusManager.getFocusedNode()?.getFocusableElement() ?? null,
)
) {
let parent: BlockSvg | undefined | null = this.getParent();
// ...
if (parent) {
focusManager.focusNode(parent);
} else {
setTimeout(() => focusManager.focusTree(this.workspace), 0);
}
}Since top blocks does not have any parent, then it will finally execute setTimeout when disposing. But this.workspace will be unregistered before focusManager.focusTree is excuted.
Reproduction steps
- Create a workspace with any block.
- Click any input of that block to focus on it.
- Dispose the workspace.
Priority
No response
Stack trace
focus_manager.ts:232 Uncaught Error: Attempted to focus unregistered tree: [object Object].
at FocusManager$$module$build$src$core$focus_manager.focusTree (focus_manager.ts:232:1)
at eval (block_svg.ts:885:1)
focusTree @ focus_manager.ts:232
eval @ block_svg.ts:885
setTimeout
dispose @ block_svg.ts:885
clear @ workspace.ts:368
clear @ workspace_svg.ts:2324
dispose @ workspace.ts:144
dispose @ workspace_svg.ts:893Screenshots
No response
Browsers
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
issue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong