Skip to content

fix(minimap): preserve field editor focus when tabbing between fields - #2768

Open
sharadvc wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
sharadvc:cursor/fix-minimap-tab-focus-3e8c
Open

sharadvc wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
sharadvc:cursor/fix-minimap-tab-focus-3e8c

Conversation

@sharadvc

Copy link
Copy Markdown

Summary

Fixes RaspberryPiFoundation/blockly#10429.

When editing a numeric field on a block and pressing Tab to move to the next field, focus briefly landed on the next field and was then lost. This happened because the minimap mirrored BLOCK_CHANGE events and then called zoomToFit() after queued renders finished. That async zoomToFit() could run while a field editor still held ephemeral focus, steal DOM focus, and close the editor.

Fix

Skip zoomToFit() while Blockly's FocusManager reports ephemeral focus (for example, while a field editor is open). The minimap still mirrors block changes immediately; only the deferred fit/zoom is deferred until editing finishes.

Testing

  • Added a regression test that reproduces the reported flow (controls_for with math_number inputs, edit the first value, press Tab).
  • All existing @blockly/workspace-minimap tests pass.

Skip zoomToFit while Blockly holds ephemeral focus for a field editor.
The async zoomToFit after BLOCK_CHANGE was stealing DOM focus and
closing the editor when tabbing between fields on the same block.

Fixes RaspberryPiFoundation/blockly-samples#2636

Co-authored-by: Sharad. <sharadvc@users.noreply.github.com>
@sharadvc
sharadvc requested a review from a team as a code owner September 11, 2026 17:08
@sharadvc
sharadvc requested review from gonfunko and removed request for a team September 11, 2026 17:08
@gonfunko

Copy link
Copy Markdown
Contributor

Thanks for the PR! This broadly seems reasonable, but we've recently moved the plugins into the core Blockly repository. Do you mind retargeting it to that repo? The minimap plugin now lives here: https://github.com/RaspberryPiFoundation/blockly/tree/main/packages/plugins/workspace-minimap

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimap affecting focus

3 participants