Skip to content

Commit 7454959

Browse files
committed
fix: A few tests.
This also removes some unnecessary code and one TODO.
1 parent 17d17b9 commit 7454959

File tree

5 files changed

+18
-33
lines changed

5 files changed

+18
-33
lines changed

src/aria_monkey_patches.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ document.createElementNS = function (namepspaceURI, qualifiedName) {
2727
};
2828

2929
const oldElementSetAttribute = Element.prototype.setAttribute;
30+
// TODO: Replace these cases with property augmentation here so that all aria
31+
// behavior is defined within this file.
32+
const ariaAttributeAllowlist = ['aria-disabled', 'aria-selected'];
3033

3134
Element.prototype.setAttribute = function (name, value) {
3235
// This is a hacky way to disable all aria changes in core Blockly since it's
3336
// easier to just undefine everything globally and then conditionally reenable
3437
// things with the correct definitions.
38+
// TODO: Add an exemption for role here once all roles are properly defined
39+
// within this file (see failing tests when role changes are ignored here).
3540
if (
3641
aria.isCurrentlyMutatingAriaProperty() ||
37-
(name !== 'role' && !name.startsWith('aria-'))
42+
ariaAttributeAllowlist.includes(name) ||
43+
!name.startsWith('aria-')
3844
) {
3945
oldElementSetAttribute.call(this, name, value);
4046
}

src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ export class KeyboardNavigation {
6666
workspace.addChangeListener(enableBlocksOnDrag);
6767

6868
// Move the flyout for logical tab order.
69-
// const flyout = workspace.getFlyout();
70-
// if (flyout != null && flyout instanceof Blockly.Flyout) {
71-
// // This relies on internals.
72-
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
73-
// const flyoutElement = ((flyout as any).svgGroup_ as SVGElement) ?? null;
74-
// flyoutElement?.parentElement?.insertBefore(
75-
// flyoutElement,
76-
// workspace.getParentSvg(),
77-
// );
78-
// }
69+
const flyout = workspace.getFlyout();
70+
if (flyout != null && flyout instanceof Blockly.Flyout) {
71+
// This relies on internals.
72+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
73+
const flyoutElement = ((flyout as any).svgGroup_ as SVGElement) ?? null;
74+
flyoutElement?.parentElement?.insertBefore(
75+
flyoutElement,
76+
workspace.getParentSvg(),
77+
);
78+
}
7979

8080
this.oldWorkspaceResize = workspace.resize;
8181
workspace.resize = () => {
@@ -296,7 +296,7 @@ export class KeyboardNavigation {
296296
stroke: var(--blockly-active-node-color);
297297
stroke-width: var(--blockly-selection-width);
298298
}
299-
299+
300300
/* The workspace itself is the active node. */
301301
.blocklyKeyboardNavigation
302302
.blocklyBubble.blocklyActiveFocus

src/move_icon.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,4 @@ export class MoveIcon implements Blockly.IIcon, Blockly.IHasBubble {
139139
canBeFocused(): boolean {
140140
return false;
141141
}
142-
143-
/** See IFocusableNode.getAriaRole. */
144-
getAriaRole(): Blockly.utils.aria.Role | null {
145-
throw new Error('This node is not focusable.');
146-
}
147-
148-
/** See IFocusableNode.getAriaLabel. */
149-
getAriaLabel(): string {
150-
throw new Error('This node is not focusable.');
151-
}
152142
}

src/move_indicator.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,4 @@ export class MoveIndicatorBubble
172172
canBeFocused(): boolean {
173173
return false;
174174
}
175-
176-
/** See IFocusableNode.getAriaRole. */
177-
getAriaRole(): Blockly.utils.aria.Role | null {
178-
throw new Error('This node is not focusable.');
179-
}
180-
181-
/** See IFocusableNode.getAriaLabel. */
182-
getAriaLabel(): string {
183-
throw new Error('This node is not focusable.');
184-
}
185175
}

src/navigation_controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {Mover} from './actions/mover';
3636
import {DuplicateAction} from './actions/duplicate';
3737
import {StackNavigationAction} from './actions/stack_navigation';
3838

39-
// TODO: Implement unregistration.
4039
import './aria_monkey_patches';
4140

4241
const KeyCodes = BlocklyUtils.KeyCodes;

0 commit comments

Comments
 (0)