8000 [Do not merge] Test prototype focus manager incorporation by BenHenning · Pull Request #8875 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Do not merge] Test prototype focus manager incorporation #8875

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0ed9db2
feat!: initial integration of FocusableTree/Node.
BenHenning Apr 9, 2025
45b1b50
feat: bunch more focus fixes.
BenHenning Apr 11, 2025
5f9de82
feat: LOTS of functionality changes.
BenHenning Apr 18, 2025
9acf144
chore: finalize focus infra changes pt1.
BenHenning Apr 21, 2025
d5b9741
chore: finalize focus infra changes pt2.
BenHenning Apr 21, 2025
931b424
Merge branch 'add-focus-manager-callbacks-and-improvements' into test…
BenHenning Apr 21, 2025
a9a4f1b
Merge branch 'add-focus-manager-callbacks-and-improvements' into test…
BenHenning Apr 21, 2025
e9a30c0
chore: another attempt to fix CSS inheritance.
BenHenning Apr 21, 2025
41c8215
feat: Make WorkspaceSvg focusable.
BenHenning Apr 21, 2025
14b486e
chore: remove accidental 'test.only'.
BenHenning Apr 21, 2025
26cf8db
feat: Make Toolbox & Flyout focusable.
BenHenning Apr 22, 2025
5ef2d7e
Merge branch 'add-focus-manager-callbacks-and-improvements' into make…
BenHenning Apr 22, 2025
996208d
Merge branch 'make-workspace-focusable' into make-toolbox-and-flyout-…
BenHenning Apr 22, 2025
f6e0dc7
Merge branch 'add-focus-manager-callbacks-and-improvements' into test…
BenHenning Apr 22, 2025
b424902
Merge branch 'make-workspace-focusable' into test-prototype-focus-man…
BenHenning Apr 22, 2025
dca3a81
Merge branch 'make-toolbox-and-flyout-focusable' into test-prototype-…
BenHenning Apr 22, 2025
82bbab6
Fix things & add ARIA labels for demo.
BenHenning Apr 22, 2025
d3acbff
feat!: Force lifecycle methods for fields.
BenHenning Apr 22, 2025
ed0f140
feat: Make fields ephemerally focusable.
BenHenning Apr 22, 2025
94672d9
chore: Lint fixes.
BenHenning Apr 22, 2025
2430646
chore: Remove incorrect aria-label.
BenHenning Apr 22, 2025
41bc01a
feat: Make RenderedConnection focusable.
BenHenning Apr 23, 2025
4479b82
Merge branch 'add-focus-manager-callbacks-and-improvements' into make…
BenHenning Apr 23, 2025
2637736
fix: Ensure Block paths are focusable.
BenHenning Apr 23, 2025
49192ba
chore: Fix line comment.
BenHenning Apr 23, 2025
917c4b6
Merge branch 'make-workspace-focusable' into make-toolbox-and-flyout-…
BenHenning Apr 23, 2025
d276dbc
chore: reduce branching.
BenHenning Apr 24, 2025
c819130
Merge branch 'make-toolbox-and-flyout-focusable' into make-fields-foc…
BenHenning Apr 24, 2025
90fdde2
feat: make drop down & widget divs focusable.
BenHenning Apr 24, 2025
7c2f705
chore: undo breaking field changes.
BenHenning Apr 24, 2025
9726389
chore: some more clean-ups after removals.
BenHenning Apr 24, 2025
1094787
feat: fix field node retrieval.
BenHenning Apr 24, 2025
082a6ef
chore: lint fixes.
BenHenning Apr 24, 2025
0006a45
Merge branch 'make-fields-focusable' into make-connections-focusable
BenHenning Apr 24, 2025
7f14372
feat: add remaining connection support
BenHenning Apr 24, 2025
59198db
chore: lint fixes.
BenHenning Apr 24, 2025
93603d3
Merge branch 'make-connections-focusable' into test-prototype-focus-m…
BenHenning Apr 24, 2025
8df19a7
chore: lint fixes for better diffing.
BenHenning Apr 24, 2025
129e417
chore: remove unnecessary field ephemeral focus.
BenHenning Apr 24, 2025
a346a92
fix: remove unnecessary shadow check.
BenHenning Apr 24, 2025
4ed61bf
Merge branch 'make-workspace-focusable' into make-toolbox-and-flyout-…
BenHenning Apr 24, 2025
898c5a4
Merge branch 'make-toolbox-and-flyout-focusable' into make-fields-foc…
BenHenning Apr 24, 2025
fdf4b4f
Merge branch 'make-fields-focusable' into make-connections-focusable
BenHenning Apr 24, 2025
26a54df
Merge branch 'make-connections-focusable' into test-prototype-focus-m…
BenHenning Apr 24, 2025
80c8859
chore: add braces.
BenHenning Apr 24, 2025
b3bd5e7
Merge branch 'rc/v12.0.0' into make-workspace-focusable
BenHenning Apr 24, 2025
1f0cefc
Merge branch 'make-workspace-focusable' into make-toolbox-and-flyout-…
BenHenning Apr 24, 2025
c2384c6
chore: empty commit to make CI pass.
BenHenning Apr 24, 2025
57391a7
Merge branch 'rc/v12.0.0' into make-toolbox-and-flyout-focusable
BenHenning Apr 24, 2025
8057051
Merge branch 'make-toolbox-and-flyout-focusable' into make-fields-foc…
BenHenning Apr 24, 2025
ad96cad
Merge branch 'make-fields-focusable' into make-connections-focusable
BenHenning Apr 24, 2025
78941e7
Merge branch 'make-connections-focusable' into test-prototype-focus-m…
BenHenning Apr 24, 2025
23c1b8f
fix: CSS issues.
BenHenning Apr 24, 2025
28d5057
fix: ensure click & focus sync.
BenHenning Apr 25, 2025
3e6a995
chore: remove a bunch of unused code.
BenHenning Apr 28, 2025
8251654
Merge branch 'rc/v12.0.0' into test-prototype-focus-manager-incorpora…
BenHenning May 15, 2025
96f033e
Merge branch 'develop' into test-prototype-focus-manager-incorporation
BenHenning May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ export class BlockSvg

// The page-wide unique ID of this Block used for focusing.
svgPath.id = idGenerator.getNextUniqueId();
svgPath.setAttribute(
'aria-label',
this.type ? '"' + this.type + '" block' : 'Block',
);

this.doInit_();
}
Expand Down
12 changes: 10 additions & 2 deletions core/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ import {
} from './interfaces/i_draggable.js';
import {IDragger} from './interfaces/i_dragger.js';
import {IFlyout} from './interfaces/i_flyout.js';
import {IFocusableNode} from './interfaces/i_focusable_node.js';
import {IFocusableTree} from './interfaces/i_focusable_tree.js';
import {
IFocusableNode,
isFocusableNode,
} from './interfaces/i_focusable_node.js';
import {
IFocusableTree,
isFocusableTree,
} from './interfaces/i_focusable_tree.js';
import {IHasBubble, hasBubble} from './interfaces/i_has_bubble.js';
import {IIcon, isIcon} from './interfaces/i_icon.js';
import {IKeyboardAccessible} from './interfaces/i_keyboard_accessible.js';
Expand Down Expand Up @@ -624,6 +630,8 @@ export {
isCopyable,
isDeletable,
isDraggable,
isFocusableNode,
isFocusableTree,
isIcon,
isObservable,
isPaster,
Expand Down
8 changes: 2 additions & 6 deletions core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ let content = `

.blocklyHighlightedConnectionPath {
fill: none;
stroke: #fc3;
stroke-width: 4px;
// stroke: #fc3;
// stroke-width: 4px;
}

.blocklyPathLight {
Expand All @@ -157,10 +157,6 @@ let content = `
stroke-width: 1;
}

.blocklySelected>.blocklyPathLight {
display: none;
}

.blocklyDraggable {
cursor: grab;
cursor: -webkit-grab;
Expand Down
8 changes: 8 additions & 0 deletions core/dropdowndiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@
animateOutTimer = setTimeout(function () {
hideWithoutAnimation();
}, ANIMATION_TIME * 1000);
if (returnEphemeralFocus) {
returnEphemeralFocus();
returnEphemeralFocus = null;
}
if (onHide) {
onHide();
>
Expand All @@ -656,6 +660,10 @@
clearTimeout(animateOutTimer);
}

if (returnEphemeralFocus) {
returnEphemeralFocus();
returnEphemeralFocus = null;
}
if (onHide) {
onHide();
>
Expand All @@ -666,7 +674,7 @@
(common.getMainWorkspace() as WorkspaceSvg).markFocused();

if (returnEphemeralFocus) {
returnEphemeralFocus();

Check failure on line 677 in core/dropdowndiv.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

This expression is not callable.

Check failure on line 677 in core/dropdowndiv.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

This expression is not callable.
returnEphemeralFocus = null;
}
}
Expand Down
24 changes: 24 additions & 0 deletions core/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
this.fieldGroup_ = dom.createSvgElement(Svg.G, {
'tabindex': '-1',
'id': id,
'aria-label': 'Field ' + this.name,
});
if (!this.isVisible()) {
this.fieldGroup_.style.display = 'none';
Expand Down Expand Up @@ -1362,7 +1363,7 @@
}

/** See IFocusableNode.getFocusableElement. */
getFocusableElement(): HTMLElement | SVGElement {

Check failure on line 1366 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1366 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.
if (!this.fieldGroup_) {
throw Error('This field currently has no representative DOM element.');
}
Expand All @@ -1370,7 +1371,7 @@
}

/** See IFocusableNode.getFocusableTree. */
getFocusableTree(): IFocusableTree {

Check failure on line 1374 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1374 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.
const block = this.getSourceBlock();
if (!block) {
throw new UnattachedFieldError();
Expand All @@ -1379,16 +1380,39 @@
}

/** See IFocusableNode.onNodeFocus. */
onNodeFocus(): void {}

Check failure on line 1383 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1383 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.

/** See IFocusableNode.onNodeBlur. */
onNodeBlur(): void {}

Check failure on line 1386 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1386 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.

/** See IFocusableNode.canBeFocused. */
canBeFocused(): boolean {
return true;
}

/** See IFocusableNode.getFocusableElement. */
getFocusableElement(): HTMLElement | SVGElement {

Check failure on line 1394 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1394 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.
if (!this.fieldGroup_) {
throw Error('This field currently has no representative DOM element.');
}
return this.fieldGroup_;
}

/** See IFocusableNode.getFocusableTree. */
getFocusableTree(): IFocusableTree {

Check failure on line 1402 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1402 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.
const block = this.getSourceBlock();
if (!block) {
throw new UnattachedFieldError();
}
return block.workspace as WorkspaceSvg;
}

/** See IFocusableNode.onNodeFocus. */
onNodeFocus(): void {}

Check failure on line 1411 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1411 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.

/** See IFocusableNode.onNodeBlur. */
onNodeBlur(): void {}

Check failure on line 1414 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 1414 in core/field.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.

/**
* Subclasses should reimplement this method to construct their Field
* subclass from a JSON arg object.
Expand Down
1 change: 1 addition & 0 deletions core/flyout_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export abstract class Flyout
this.svgGroup_ = dom.createSvgElement(tagName, {
'class': 'blocklyFlyout',
'tabindex': '0',
'aria-label': 'Flyout',
});
this.svgGroup_.style.display = 'none';
this.svgBackground_ = dom.createSvgElement(
Expand Down
4 changes: 4 additions & 0 deletions core/gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ export class Gesture {
if (this.targetBlock) {
this.bringBlockToFront();
this.targetBlock.workspace.hideChaff(!!this.flyout);
getFocusManager().focusNode(this.targetBlock);
this.targetBlock.showContextMenu(e);
} else if (this.startBubble) {
this.startBubble.showContextMenu(e);
Expand Down Expand Up @@ -929,6 +930,9 @@ export class Gesture {
'block',
);
eventUtils.fire(event);
if (this.targetBlock) {
getFocusManager().focusNode(this.targetBlock);
}
}
this.bringBlockToFront();
eventUtils.setGroup(false);
Expand Down
8 changes: 8 additions & 0 deletions core/rendered_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,14 @@
return this;
}

private findHighlightSvg(): SVGElement | null {

Check failure on line 598 in core/rendered_connection.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20.x)

Duplicate function implementation.

Check failure on line 598 in core/rendered_connection.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22.x)

Duplicate function implementation.
// This cast is valid as TypeScript's definition is wrong. See:
// https://github.com/microsoft/TypeScript/issues/60996.
return document.getElementById(this.id) as
| unknown
| null as SVGElement | null;
}

/**
* Handles showing the context menu when it is opened on a connection.
* Note that typically the context menu can't be opened with the mouse
Expand Down
12 changes: 3 additions & 9 deletions core/renderers/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,16 +1196,10 @@ export class ConstantProvider {
`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,
`}`,

// Selection highlight.
`${selector} .blocklySelected>.blocklyPath {`,
`stroke: #fc3;`,
`stroke-width: 3px;`,
`}`,

// Connection highlight.
`${selector} .blocklyHighlightedConnectionPath {`,
`stroke: #fc3;`,
`}`,
// `${selector} .blocklyHighlightedConnectionPath {`,
// `stroke: #fc3;`,
// `}`,

// Replaceable highlight.
`${selector} .blocklyReplaceable .blocklyPath {`,
Expand Down
7 changes: 7 additions & 0 deletions core/renderers/common/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ export class Drawer {
if (highlightSvg) {
highlightSvg.style.display = elem.highlighted ? '' : 'none';
}
// if (elem.highlighted) {
// this.drawConnectionHighlightPath(elem);
// } else {
// this.block_.pathObject.removeConnectionHighlight?.(
// elem.connectionModel,
// );
// }
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions core/renderers/common/path_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ export class PathObject implements IPathObject {
* removed.
*/
protected setClass_(className: string, add: boolean) {
this.setClassOnElem_(this.svgRoot, className, add);
}

private setClassOnElem_(root: SVGElement, className: string, add: boolean) {
if (!className) {
return;
}
if (add) {
dom.addClass(this.svgRoot, className);
dom.addClass(root, className);
} else {
dom.removeClass(this.svgRoot, className);
dom.removeClass(root, className);
}
}

Expand Down Expand Up @@ -161,7 +165,7 @@ export class PathObject implements IPathObject {
* @param enable True if selection is enabled, false otherwise.
*/
updateSelected(enable: boolean) {
this.setClass_('blocklySelected', enable);
this.setClassOnElem_(this.svgPath, 'blocklySelected', enable);
}

/**
Expand Down Expand Up @@ -245,6 +249,8 @@ export class PathObject implements IPathObject {
},
this.svgRoot,
);
// TODO: Do this in a cleaner way. One possibility: create the path without 'd' or 'transform' in RenderedConnection, then just update it here (and keep registrations).
(highlight as any).renderedConnection = connection;
this.connectionHighlights.set(connection, highlight);
return highlight;
}
Expand Down
1 change: 1 addition & 0 deletions core/toolbox/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export class ToolboxCategory
aria.setRole(this.htmlDiv_, aria.Role.TREEITEM);
aria.setState(this.htmlDiv_, aria.State.SELECTED, false);
aria.setState(this.htmlDiv_, aria.State.LEVEL, this.level_ + 1);
this.htmlDiv_.setAttribute('aria-label', 'Category ' + this.name_);

this.rowDiv_ = this.createRowContainer_();
this.rowDiv_.style.pointerEvents = 'auto';
Expand Down
1 change: 1 addition & 0 deletions core/toolbox/separator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class ToolboxSeparator extends ToolboxItem {
dom.addClass(container, className);
}
this.htmlDiv = container;
this.htmlDiv.setAttribute('aria-label', 'Separator');
return container;
}

Expand Down
9 changes: 5 additions & 4 deletions core/toolbox/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class Toolbox
this.flyout = this.createFlyout_();

this.HtmlDiv = this.createDom_(this.workspace_);
this.HtmlDiv.setAttribute('aria-label', 'Toolbox');
const flyoutDom = this.flyout.createDom('svg');
dom.addClass(flyoutDom, 'blocklyToolboxFlyout');
dom.insertAfter(flyoutDom, svg);
Expand Down Expand Up @@ -965,7 +966,7 @@ export class Toolbox
*
* @returns True if a parent category was selected, false otherwise.
*/
private selectParent(): boolean {
selectParent(): boolean {
if (!this.selectedItem_) {
return false;
}
Expand Down Expand Up @@ -993,7 +994,7 @@ export class Toolbox
*
* @returns True if a child category was selected, false otherwise.
*/
private selectChild(): boolean {
selectChild(): boolean {
if (!this.selectedItem_ || !this.selectedItem_.isCollapsible()) {
return false;
}
Expand All @@ -1012,7 +1013,7 @@ export class Toolbox
*
* @returns True if a next category was selected, false otherwise.
*/
private selectNext(): boolean {
selectNext(): boolean {
if (!this.selectedItem_) {
return false;
}
Expand All @@ -1037,7 +1038,7 @@ export class Toolbox
*
* @returns True if a previous category was selected, false otherwise.
*/
private selectPrevious(): boolean {
selectPrevious(): boolean {
if (!this.selectedItem_) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ export class WorkspaceSvg
// Only the top-level workspace should be tabbable.
'tabindex': injectionDiv ? '0' : '-1',
'id': this.id,
'aria-label': 'Workspace',
});
if (injectionDiv) {
aria.setState(
Expand Down
Loading
0