Fix keyboard shortcuts (Copy/Cut/Delete) when using lasso selection#145
Fix keyboard shortcuts (Copy/Cut/Delete) when using lasso selection#145bmouse116 wants to merge 2 commits into
Conversation
|
@bmouse116 thanks! Definitely need some tests to cover this fix though. I am wondered if based on your description perhaps it can be fixed on selection side since you say it is not properly returning a multiselect draggable when it should be. If it did perhaps the existing shortcut code would work? Wondering if we need more tests here to cover this if certain slection paths aren't correctly returning a multiselect draggable. Can you try adding selection tests for the paths you found to be failing here to show they are not returning a multiselect draggable when they should be. |
|
Hi @mjgallag That keyboard shortcuts (specifically Delete) function correctly after selecting blocks with the Lasso tool. |
|
Awesome. I am on vacation but will review upon my return, thank you! |
The basics
The details
Resolves
Fixes #144
Proposed Changes
Modified registerShortcutDelete, registerCopy, and registerCut in multiselect_shortcut.js.
The updated logic now checks the dragSelection map directly within the shortcut callbacks. If the map is not empty, the shortcuts will operate on the contained blocks/comments, even if Blockly.common.getSelected() does not return a MultiselectDraggable proxy instance at that moment.
Reason for Changes
Reason for Changes
In certain states — specifically when multiselect mode is toggled via an external UI button or when using Lasso selection — the internal dragSelection map becomes populated, but the global Blockly selection state might not yet be synchronized with the MultiselectDraggable wrapper.
Before this change, shortcuts would only work if getSelected() returned a MultiselectDraggable instance, causing them to fail during Lasso selection. This PR ensures that visual selection (the blocks you actually see highlighted) always matches the shortcut behavior.
Test Coverage
Manual testing was performed in Chrome:
Documentation
N/A
Additional Information
N/A