Skip to content

Commit 15ced80

Browse files
committed
Revert "feat: Make WorkspaceSvg and BlockSvg focusable (RaspberryPiFoundation#8916)"
This reverts commit d7680cf.
1 parent 023358e commit 15ced80

File tree

4 files changed

+9
-103
lines changed

4 files changed

+9
-103
lines changed

core/block_svg.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ import {IContextMenu} from './interfaces/i_contextmenu.js';
4444
import type {ICopyable} from './interfaces/i_copyable.js';
4545
import {IDeletable} from './interfaces/i_deletable.js';
4646
import type {IDragStrategy, IDraggable} from './interfaces/i_draggable.js';
47-
import type {IFocusableNode} from './interfaces/i_focusable_node.js';
48-
import type {IFocusableTree} from './interfaces/i_focusable_tree.js';
4947
import {IIcon} from './interfaces/i_icon.js';
5048
import * as internalConstants from './internal_constants.js';
5149
import {MarkerManager} from './marker_manager.js';
@@ -78,8 +76,7 @@ export class BlockSvg
7876
IContextMenu,
7977
ICopyable<BlockCopyData>,
8078
IDraggable,
81-
IDeletable,
82-
IFocusableNode
79+
IDeletable
8380
{
8481
/**
8582
* Constant for identifying rows that are to be rendered inline.
@@ -213,7 +210,6 @@ export class BlockSvg
213210

214211
// Expose this block's ID on its top-level SVG group.
215212
this.svgGroup.setAttribute('data-id', this.id);
216-
svgPath.id = this.id;
217213

218214
this.doInit_();
219215
}
@@ -1823,26 +1819,4 @@ export class BlockSvg
18231819
);
18241820
}
18251821
}
1826-
1827-
/** See IFocusableNode.getFocusableElement. */
1828-
getFocusableElement(): HTMLElement | SVGElement {
1829-
return this.pathObject.svgPath;
1830-
}
1831-
1832-
/** See IFocusableNode.getFocusableTree. */
1833-
getFocusableTree(): IFocusableTree {
1834-
return this.workspace;
1835-
}
1836-
1837-
/** See IFocusableNode.onNodeFocus. */
1838-
onNodeFocus(): void {
1839-
common.setSelected(this);
1840-
}
1841-
1842-
/** See IFocusableNode.onNodeBlur. */
1843-
onNodeBlur(): void {
1844-
if (common.getSelected() === this) {
1845-
common.setSelected(null);
1846-
}
1847-
}
18481822
}

core/inject.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import * as common from './common.js';
1313
import * as Css from './css.js';
1414
import * as dropDownDiv from './dropdowndiv.js';
1515
import {Grid} from './grid.js';
16+
import {Msg} from './msg.js';
1617
import {Options} from './options.js';
1718
import {ScrollbarPair} from './scrollbar_pair.js';
1819
import {ShortcutRegistry} from './shortcut_registry.js';
1920
import * as Tooltip from './tooltip.js';
2021
import * as Touch from './touch.js';
22+
import * as aria from './utils/aria.js';
2123
import * as dom from './utils/dom.js';
2224
import {Svg} from './utils/svg.js';
2325
import * as WidgetDiv from './widgetdiv.js';
@@ -54,6 +56,8 @@ export function inject(
5456
if (opt_options?.rtl) {
5557
dom.addClass(subContainer, 'blocklyRTL');
5658
}
59+
subContainer.tabIndex = 0;
60+
aria.setState(subContainer, aria.State.LABEL, Msg['WORKSPACE_ARIA_LABEL']);
5761

5862
containerElement!.appendChild(subContainer);
5963
const svg = createDom(subContainer, options);
@@ -122,6 +126,7 @@ function createDom(container: HTMLElement, options: Options): SVGElement {
122126
'xmlns:xlink': dom.XLINK_NS,
123127
'version': '1.1',
124128
'class': 'blocklySvg',
129+
'tabindex': '0',
125130
},
126131
container,
127132
);

core/renderers/common/path_object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class PathObject implements IPathObject {
6262
/** The primary path of the block. */
6363
this.svgPath = dom.createSvgElement(
6464
Svg.PATH,
65-
{'class': 'blocklyPath', 'tabindex': '-1'},
65+
{'class': 'blocklyPath'},
6666
this.svgRoot,
6767
);
6868

core/workspace_svg.ts

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,13 @@ import {EventType} from './events/type.js';
3737
import * as eventUtils from './events/utils.js';
3838
import {Flyout} from './flyout_base.js';
3939
import type {FlyoutButton} from './flyout_button.js';
40-
import {getFocusManager} from './focus_manager.js';
4140
import {Gesture} from './gesture.js';
4241
import {Grid} from './grid.js';
4342
import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js';
4443
import type {IBoundedElement} from './interfaces/i_bounded_element.js';
4544
import {IContextMenu} from './interfaces/i_contextmenu.js';
4645
import type {IDragTarget} from './interfaces/i_drag_target.js';
4746
import type {IFlyout} from './interfaces/i_flyout.js';
48-
import type {IFocusableNode} from './interfaces/i_focusable_node.js';
49-
import type {IFocusableTree} from './interfaces/i_focusable_tree.js';
5047
import type {IMetricsManager} from './interfaces/i_metrics_manager.js';
5148
import type {IToolbox} from './interfaces/i_toolbox.js';
5249
import type {
@@ -57,7 +54,6 @@ import type {LineCursor} from './keyboard_nav/line_cursor.js';
5754
import type {Marker} from './keyboard_nav/marker.js';
5855
import {LayerManager} from './layer_manager.js';
5956
import {MarkerManager} from './marker_manager.js';
60-
import {Msg} from './msg.js';
6157
import {Options} from './options.js';
6258
import * as Procedures from './procedures.js';
6359
import * as registry from './registry.js';
@@ -70,7 +66,6 @@ import {Classic} from './theme/classic.js';
7066
import {ThemeManager} from './theme_manager.js';
7167
import * as Tooltip from './tooltip.js';
7268
import type {Trashcan} from './trashcan.js';
73-
import * as aria from './utils/aria.js';
7469
import * as arrayUtils from './utils/array.js';
7570
import {Coordinate} from './utils/coordinate.js';
7671
import * as dom from './utils/dom.js';
@@ -98,7 +93,7 @@ const ZOOM_TO_FIT_MARGIN = 20;
9893
*/
9994
export class WorkspaceSvg
10095
extends Workspace
101-
implements IASTNodeLocationSvg, IContextMenu, IFocusableNode, IFocusableTree
96+
implements IASTNodeLocationSvg, IContextMenu
10297
{
10398
/**
10499
* A wrapper function called when a resize event occurs.
@@ -769,19 +764,7 @@ export class WorkspaceSvg
769764
* <g class="blocklyBubbleCanvas"></g>
770765
* </g>
771766
*/
772-
this.svgGroup_ = dom.createSvgElement(Svg.G, {
773-
'class': 'blocklyWorkspace',
774-
// Only the top-level workspace should be tabbable.
775-
'tabindex': injectionDiv ? '0' : '-1',
776-
'id': this.id,
777-
});
778-
if (injectionDiv) {
779-
aria.setState(
780-
this.svgGroup_,
781-
aria.State.LABEL,
782-
Msg['WORKSPACE_ARIA_LABEL'],
783-
);
784-
}
767+
this.svgGroup_ = dom.createSvgElement(Svg.G, {'class': 'blocklyWorkspace'});
785768

786769
// Note that a <g> alone does not receive mouse events--it must have a
787770
// valid target inside it. If no background class is specified, as in the
@@ -857,9 +840,6 @@ export class WorkspaceSvg
857840
this.getTheme(),
858841
isParentWorkspace ? this.getInjectionDiv() : undefined,
859842
);
860-
861-
getFocusManager().registerTree(this);
862-
863843
return this.svgGroup_;
864844
}
865845

@@ -944,10 +924,6 @@ export class WorkspaceSvg
944924
document.body.removeEventListener('wheel', this.dummyWheelListener);
945925
this.dummyWheelListener = null;
946926
}
947-
948-
if (getFocusManager().isRegistered(this)) {
949-
getFocusManager().unregisterTree(this);
950-
}
951927
}
952928

953929
/**
@@ -2642,55 +2618,6 @@ export class WorkspaceSvg
26422618
deltaY *= scale;
26432619
this.scroll(this.scrollX + deltaX, this.scrollY + deltaY);
26442620
}
2645-
2646-
/** See IFocusableNode.getFocusableElement. */
2647-
getFocusableElement(): HTMLElement | SVGElement {
2648-
return this.svgGroup_;
2649-
}
2650-
2651-
/** See IFocusableNode.getFocusableTree. */
2652-
getFocusableTree(): IFocusableTree {
2653-
return this;
2654-
}
2655-
2656-
/** See IFocusableNode.onNodeFocus. */
2657-
onNodeFocus(): void {}
2658-
2659-
/** See IFocusableNode.onNodeBlur. */
2660-
onNodeBlur(): void {}
2661-
2662-
/** See IFocusableTree.getRootFocusableNode. */
2663-
getRootFocusableNode(): IFocusableNode {
2664-
return this;
2665-
}
2666-
2667-
/** See IFocusableTree.getRestoredFocusableNode. */
2668-
getRestoredFocusableNode(
2669-
previousNode: IFocusableNode | null,
2670-
): IFocusableNode | null {
2671-
if (!previousNode) {
2672-
return this.getTopBlocks(true)[0] ?? null;
2673-
} else return null;
2674-
}
2675-
2676-
/** See IFocusableTree.getNestedTrees. */
2677-
getNestedTrees(): Array<IFocusableTree> {
2678-
return [];
2679-
}
2680-
2681-
/** See IFocusableTree.lookUpFocusableNode. */
2682-
lookUpFocusableNode(id: string): IFocusableNode | null {
2683-
return this.getBlockById(id) as IFocusableNode;
2684-
}
2685-
2686-
/** See IFocusableTree.onTreeFocus. */
2687-
onTreeFocus(
2688-
_node: IFocusableNode,
2689-
_previousTree: IFocusableTree | null,
2690-
): void {}
2691-
2692-
/** See IFocusableTree.onTreeBlur. */
2693-
onTreeBlur(_nextTree: IFocusableTree | null): void {}
26942621
}
26952622

26962623
/**

0 commit comments

Comments
 (0)