-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Announce the workspace to VoiceOver via a focus target node #10087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gonfunko
merged 4 commits into
RaspberryPiFoundation:main
from
microbit-matt-hillsdon:workspace-focus-node
Jun 29, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
372ef7c
fix: Announce the workspace to VoiceOver via a focus target node
microbit-matt-hillsdon 4adc0fc
Remove policy that turns out not to be needed
microbit-matt-hillsdon ea59d45
chore: fix copyright notice
microbit-matt-hillsdon dd22c37
Merge branch 'main' into workspace-focus-node
microbit-matt-hillsdon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
89 changes: 89 additions & 0 deletions
89
...blockly/core/keyboard_nav/navigation_policies/workspace_focus_target_navigation_policy.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type {IFocusableNode} from '../../interfaces/i_focusable_node.js'; | ||
| import type {INavigationPolicy} from '../../interfaces/i_navigation_policy.js'; | ||
| import {WorkspaceFocusTarget} from '../../workspace_focus_target.js'; | ||
|
|
||
| /** | ||
| * Set of rules controlling keyboard navigation from the workspace focus target. | ||
| * | ||
| * The focus target represents the workspace as a whole (reached via the focus | ||
| * workspace shortcut or when first entering the workspace), so navigating into | ||
| * it should mirror navigating into the workspace itself. | ||
| */ | ||
| export class WorkspaceFocusTargetNavigationPolicy implements INavigationPolicy<WorkspaceFocusTarget> { | ||
| /** | ||
| * Returns the first child of the focus target's workspace. | ||
| * | ||
| * @param current The focus target to return the first child of. | ||
| * @returns The top block of the first block stack, if any. | ||
| */ | ||
| getFirstChild(current: WorkspaceFocusTarget): IFocusableNode | null { | ||
| const blocks = current.getWorkspace().getTopBlocks(true); | ||
| return blocks.length ? blocks[0] : null; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the parent of the given focus target. | ||
| * | ||
| * @param _current The focus target to return the parent of. | ||
| * @returns Null. | ||
| */ | ||
| getParent(_current: WorkspaceFocusTarget): IFocusableNode | null { | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the next sibling of the given focus target. | ||
| * | ||
| * @param _current The focus target to return the next sibling of. | ||
| * @returns Null. | ||
| */ | ||
| getNextSibling(_current: WorkspaceFocusTarget): IFocusableNode | null { | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the previous sibling of the given focus target. | ||
| * | ||
| * @param _current The focus target to return the previous sibling of. | ||
| * @returns Null. | ||
| */ | ||
| getPreviousSibling(_current: WorkspaceFocusTarget): IFocusableNode | null { | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the row ID of the given focus target. | ||
| * | ||
| * @param current The focus target to retrieve the row ID of. | ||
| * @returns The row ID of the focus target's workspace. | ||
| */ | ||
| getRowId(current: WorkspaceFocusTarget): string { | ||
| return current.getWorkspace().id; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether or not the given focus target can be navigated to. | ||
| * | ||
| * @param current The instance to check for navigability. | ||
| * @returns True if the given focus target can be focused. | ||
| */ | ||
| isNavigable(current: WorkspaceFocusTarget): boolean { | ||
| return current.canBeFocused(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether the given object can be navigated from by this policy. | ||
| * | ||
| * @param current The object to check if this policy applies to. | ||
| * @returns True if the object is a WorkspaceFocusTarget. | ||
| */ | ||
| isApplicable(current: any): current is WorkspaceFocusTarget { | ||
| return current instanceof WorkspaceFocusTarget; | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type {IFocusableNode} from './interfaces/i_focusable_node.js'; | ||
| import type {IFocusableTree} from './interfaces/i_focusable_tree.js'; | ||
| import type {WorkspaceSvg} from './workspace_svg.js'; | ||
|
|
||
| /** | ||
| * A focusable element representing the workspace as a whole. | ||
| * | ||
| * Focus on the workspace itself (i.e. not on any block, comment, or other | ||
| * content) lands here rather than on the workspace's region element. VoiceOver | ||
| * does not announce a region when focus moves into it from a node already | ||
| * inside that region, so focusing the region directly (e.g. after pressing "W" | ||
| * from a block) would be silent. This is an ordinary focusable node, so moving | ||
| * to it is announced. It carries the stack count and a "workspace" role | ||
| * description; the enclosing region keeps a short, stable label | ||
| * ("Blocks workspace."). | ||
| */ | ||
| export class WorkspaceFocusTarget implements IFocusableNode { | ||
| /** | ||
| * @param workspace The workspace this focus target represents. | ||
| * @param element The SVG element that receives focus for the workspace. | ||
| */ | ||
| constructor( | ||
| private readonly workspace: WorkspaceSvg, | ||
| private readonly element: SVGElement, | ||
| ) {} | ||
|
|
||
| /** See IFocusableNode.getFocusableElement. */ | ||
| getFocusableElement(): SVGElement { | ||
| return this.element; | ||
| } | ||
|
|
||
| /** See IFocusableNode.getFocusableTree. */ | ||
| getFocusableTree(): IFocusableTree { | ||
| return this.workspace; | ||
| } | ||
|
|
||
| /** See IFocusableNode.onNodeFocus. */ | ||
| onNodeFocus(): void { | ||
| this.workspace.handleWorkspaceFocusTargetFocus(); | ||
| } | ||
|
|
||
| /** See IFocusableNode.onNodeBlur. */ | ||
| onNodeBlur(): void {} | ||
|
|
||
| /** See IFocusableNode.canBeFocused. */ | ||
| canBeFocused(): boolean { | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the workspace this focus target represents. | ||
| * | ||
| * @returns The workspace this focus target represents. | ||
| */ | ||
| getWorkspace(): WorkspaceSvg { | ||
| return this.workspace; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2026 Raspberry Pi Foundation