feat: ctrl/cmd+v pastes near focused block#10061
Merged
Merged
Conversation
maribethb
approved these changes
Jun 24, 2026
| return !!clipboard.paste(copyData, targetWorkspace, mouseCoords); | ||
| } | ||
|
|
||
| // If the focused node is a block, paste relative to that block's position. |
Contributor
There was a problem hiding this comment.
I think this comment is very slightly inaccurate, it's if the focus node is a block or part of a block (e.g. connection or field)
| const pasteOrigin = block?.getRelativeToSurfaceXY(); | ||
| if (pasteOrigin) { | ||
| return !!clipboard.paste(copyData, targetWorkspace, pasteOrigin); | ||
| } |
Contributor
There was a problem hiding this comment.
it would be super cool if when:
- a connection is focused
- the copied block is compatible with that connection
we connected the block to the connection automatically
but that could be a follow up feature too :)
Contributor
Author
There was a problem hiding this comment.
I think that was discussed in RaspberryPiFoundation/blockly-keyboard-experimentation#480. There were concerns that auto-connecting on paste could have surprising effects (popping out blocks, unexpected nesting, etc.), and that people often use copy/paste to reuse a block elsewhere rather than insert it at the current location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #9091
Proposed Changes
This updates the
'paste'shortcut to use a currently focused block's position instead of the position included in thecopyData. If a block's child is focused (e.g., connection, comment editor, etc.), the source block's position is used. If the workspace is focused, there is no change to the behavior.Reason for Changes
Previously, if the user copied in one location with the keyboard and then moved to a different block, the paste would occur near the original copied block's location.
Test Coverage
Added new relevant tests.