Open jlaurens opened 6 years ago
Agreed, we should only handle keyboard events for Blockly when the user is focused on a Blockly component.
Related (?), Command Z in Safari will also reopen a closed tab, which happens in parallel with undoing the action in Blockly.
There is a concurrency between Blockly undo management and browser undo management.
This affects safari and google chrome but does not affect firefox at least on OS X.
Take the fixed blockly demo at
blockly/demos/fixed/index.html
and add atextarea
. If you perform changes in both the text area and the workspace, undo/redo with key shortcut merges Blockly undo management and browser undo management.Here are the steps: 1) load the modified page 2) enter some text in the text area 3) drag some block in the workspace 4) trigger an undo event with the key shortcut
Problem: both the text area and the workspace are reverted during the same operation. Expected behaviour: when the workspace has the focus, the undo/redo actions should apply to the workspace only.
Ideally, when the workspace has the focus, the menu item undo/redo action of the browser should apply to the workspace only.
Newer repro steps (2023/11/21)
1) Run
npm run start
to open the playground. 2) Type some text into the text field on the left. 3) Drag a block into the workspace. 4) Trigger an undo with a keyboard shortcut. 5) Observe how the block is deleted and the text change is reverted. Expect the text to not be modified.To Fix
Edit the keyboard shortcuts for undo and redo to call
preventDefault
on the event they are passed. You will need to add an extra event parameter to thecallback
method. Check out the type definition for keyboard shortcuts.