Skip to content

fix: focus the workspace itself on first focus#9974

Merged
maribethb merged 2 commits into
RaspberryPiFoundation:v13from
maribethb:workspace-focus
Jun 11, 2026
Merged

fix: focus the workspace itself on first focus#9974
maribethb merged 2 commits into
RaspberryPiFoundation:v13from
maribethb:workspace-focus

Conversation

@maribethb

@maribethb maribethb commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #9969

Proposed Changes

  • For non-mutator, non-flyout workspaces, focuses the workspace itself on first focus, not the first block. reduces cognitive overload for screenreader users and actually reads the screenreader mode hint we added.
  • No change for mutators and flyouts: focuses the first block or focusable item
  • Added new tests for the above behavior
  • Previously, mutator workspaces said that their focusable tree was actually the parent workspace. This causes problems. Changed it so they return themselves. See next section for details.
  • Fixed an issue with a tooltip test not rendering the blocks, causing the test to pass by luck of the way previous things worked

Reason for Changes

See issue description for why the first change.

As to why the change to getFocusableTree in workspace_svg:

At an intermediate step in this PR, I had mutator workspaces also returning the workspace itself for initial focus rather than the first block. This revealed problems with getFocusableTree returning the parent workspace. It caused the escape shortcut to behave incorrectly, T to open the main workspace toolbox instead of the flyout toolbox, etc. Basically there was almost no way previously to actually put the focus on the mutator workspace itself (since mutator workspaces are never empty) and so the condition where workspace.getFocusableTree was actually hitting the mutator case never occurred. blocks on the mutator workspace did not participate in the same lie where they said that their tree was the main workspace tree. they correctly reported the mutator workspace tree.

I audited the cases where the mutator workspace being focused and getFocusableTree is called. Here are the results:

Consumer Effect of returning parent for mutator root
FocusManager.getFocusedTree() Wrong tree (main workspace)
globalShortcutHandler Routes shortcuts to main workspace instead of mutator
Navigator.getTopLevelItems() Lists main workspace blocks instead of mutator blocks
FocusManager tree-switching / highlight logic Treats mutator root as belonging to parent tree

All of these are actually the wrong behavior. It just never mattered before since the mutator workspace was never focused.

Then after I fixed these problems, I realized it actually made more sense for mutator workspaces to continue focusing their first block, unlike the main workspace. So this again goes back to not mattering since it is very difficult to actually focus the mutator workspace again. But, this behavior is more correct, and if we change our mind in the future about focusing the first block for mutator workspaces, we can easily change that without hitting these same problems.

Test Coverage

added unit tests, fixed existing ones (that were relying on implementation details to pass). manually tested main workspaces, flyout workspaces, and mutator workspaces.

Documentation

n/a

Additional Information

@maribethb maribethb requested a review from a team as a code owner June 10, 2026 20:02
@maribethb maribethb requested a review from mikeharv June 10, 2026 20:02
@github-actions github-actions Bot added the PR: fix Fixes a bug label Jun 10, 2026
Comment thread packages/blockly/core/workspace_svg.ts
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Jun 11, 2026
@maribethb maribethb changed the title fix: focus the workspace not the first block fix: focus the workspace itself on first focus Jun 11, 2026
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Jun 11, 2026
@mikeharv mikeharv self-requested a review June 11, 2026 15:21

@mikeharv mikeharv left a comment

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.

Thanks for the detailed notes. Pulled and manually tested.

@maribethb maribethb merged commit ed761c3 into RaspberryPiFoundation:v13 Jun 11, 2026
9 checks passed
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.

2 participants