Skip to content

fix: Focus nearest neighbor when deleting a focused block#9599

Merged
gonfunko merged 7 commits intomainfrom
delete-focus
Feb 26, 2026
Merged

fix: Focus nearest neighbor when deleting a focused block#9599
gonfunko merged 7 commits intomainfrom
delete-focus

Conversation

@gonfunko
Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #9585

Proposed Changes

This PR adjusts the focus behavior when a focused block is deleted. Previously, deleting a focused block would focus the workspace, which would in turn focus the first (left/topmost) block on the workspace. This could cause large jumps in scroll position. Now, when a focused block is deleted, it moves focus to the closest remaining block, resulting in a smaller (or no) workspace movement.

The tests were partially LLM-generated in response to a list of testcases I specified. I reviewed, modified them, and manually added an additional testcase.

@gonfunko gonfunko requested a review from a team as a code owner February 24, 2026 22:28
@gonfunko gonfunko requested a review from BenHenning February 24, 2026 22:28
@github-actions github-actions bot added the PR: fix Fixes a bug label Feb 24, 2026
Copy link
Copy Markdown
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @gonfunko! Largely LGTM but had a few thoughts--PTAL.

@BenHenning BenHenning assigned gonfunko and unassigned BenHenning Feb 25, 2026
@gonfunko
Copy link
Copy Markdown
Contributor Author

This also fixes #9601

@gonfunko gonfunko assigned BenHenning and unassigned gonfunko Feb 25, 2026
@gonfunko gonfunko requested a review from BenHenning February 25, 2026 18:45
Copy link
Copy Markdown
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @gonfunko!

@BenHenning BenHenning assigned gonfunko and unassigned BenHenning Feb 26, 2026
@gonfunko gonfunko merged commit 3d78491 into main Feb 26, 2026
10 of 19 checks passed
@gonfunko gonfunko deleted the delete-focus branch February 26, 2026 18:45
Kh0anh added a commit to Kh0anh/QuantFlow that referenced this pull request Mar 23, 2026
- Add window-level error handler to catch and suppress the known Blockly v12
  "Attempted to focus unregistered tree" runtime error (RaspberryPiFoundation/blockly#9599)
- Error occurs when a workspace inside a display:none container receives a
  focus event before the FocusManager re-registers the tree
- Handler prevents the Next.js error overlay from appearing in dev mode
  while the upstream fix is pending in Blockly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a top-level selected block scrolls the workspace to the top left

2 participants