Skip to content

Commit a671390

Browse files
committed
fix: Fix registration exceptions on reinjection.
1 parent 1242271 commit a671390

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ async function createWorkspace(): Promise<Blockly.WorkspaceSvg> {
9797
KeyboardNavigation.registerKeyboardNavigationStyles();
9898
registerFlyoutCursor();
9999
registerNavigationDeferringToolbox();
100+
registerRunCodeShortcut();
101+
Blockly.ContextMenuItems.registerCommentOptions();
100102

103+
let navigation: KeyboardNavigation | null = null;
101104
const workspace = (
102105
await createPlayground(
103106
blocklyDiv,
104107
(blocklyDiv, options) => {
108+
if (navigation) {
109+
navigation.dispose();
110+
}
105111
const ws = Blockly.inject(blocklyDiv, options);
106-
Blockly.ContextMenuItems.registerCommentOptions();
107-
new KeyboardNavigation(ws);
108-
registerRunCodeShortcut();
112+
navigation = new KeyboardNavigation(ws);
109113

110114
// Disable blocks that aren't inside the setup or draw loops.
111115
ws.addChangeListener(Blockly.Events.disableOrphans);

0 commit comments

Comments
 (0)