Skip to content

Commit 6869679

Browse files
cpcallenBenHenning
andauthored
fix(actions): Fix shortcut wrappers broken by RaspberryPiFoundation/blockly#8917 (#487)
Co-authored-by: Ben Henning <[email protected]>
1 parent 8e1c265 commit 6869679

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/actions/undo_redo.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {ShortcutRegistry, ShortcutItems, WorkspaceSvg} from 'blockly/core';
7+
import {
8+
ContextMenuRegistry,
9+
ShortcutRegistry,
10+
ShortcutItems,
11+
WorkspaceSvg,
12+
} from 'blockly/core';
813

914
/**
1015
* Class for registering a shortcut for undo/redo actions.
@@ -22,9 +27,12 @@ export class UndoRedoAction {
2227
this.originalUndo = undo;
2328
const patchedUndo = {
2429
...this.originalUndo,
25-
preconditionFn: (workspace: WorkspaceSvg) => {
30+
preconditionFn: (
31+
workspace: WorkspaceSvg,
32+
scope: ContextMenuRegistry.Scope,
33+
) => {
2634
return !!(
27-
!workspace.isDragging() && undo.preconditionFn?.(workspace)
35+
!workspace.isDragging() && undo.preconditionFn?.(workspace, scope)
2836
);
2937
},
3038
allowCollision: true,
@@ -39,9 +47,12 @@ export class UndoRedoAction {
3947
this.originalRedo = redo;
4048
const patchedRedo = {
4149
...this.originalRedo,
42-
preconditionFn: (workspace: WorkspaceSvg) => {
50+
preconditionFn: (
51+
workspace: WorkspaceSvg,
52+
scope: ContextMenuRegistry.Scope,
53+
) => {
4354
return !!(
44-
!workspace.isDragging() && redo.preconditionFn?.(workspace)
55+
!workspace.isDragging() && redo.preconditionFn?.(workspace, scope)
4556
);
4657
},
4758
allowCollision: true,

0 commit comments

Comments
 (0)