Skip to content

feat: ctrl/cmd+v pastes near focused block#10061

Open
mikeharv wants to merge 3 commits into
RaspberryPiFoundation:mainfrom
mikeharv:paste-near-focus
Open

feat: ctrl/cmd+v pastes near focused block#10061
mikeharv wants to merge 3 commits into
RaspberryPiFoundation:mainfrom
mikeharv:paste-near-focus

Conversation

@mikeharv

@mikeharv mikeharv commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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 the copyData. 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.

@github-actions github-actions Bot added PR: feature Adds a feature and removed PR: feature Adds a feature labels Jun 24, 2026
@mikeharv mikeharv marked this pull request as ready for review June 24, 2026 18:05
@mikeharv mikeharv requested a review from a team as a code owner June 24, 2026 18:05
@mikeharv mikeharv requested a review from maribethb June 24, 2026 18:05
@github-actions github-actions Bot removed the PR: feature Adds a feature label Jun 24, 2026
@github-actions github-actions Bot added the PR: feature Adds a feature label Jun 24, 2026
return !!clipboard.paste(copyData, targetWorkspace, mouseCoords);
}

// If the focused node is a block, paste relative to that block's position.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be super cool if when:

  1. a connection is focused
  2. 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pasting with ctrl-v should paste near the currently selected block

2 participants