Skip to content

Commit bf576d5

Browse files
authored
fix: improve aria markup for toolboxes (#9398)
* fix: set activedescendant correctly on toolbox * fix: dont manually set posinset for toolbox categories * fix: dont set activedescendant on toolbox at all
1 parent 3cf834a commit bf576d5

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

core/toolbox/collapsible_category.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,6 @@ export class CollapsibleToolboxCategory
137137
aria.setState(this.htmlDiv_ as HTMLDivElement, aria.State.EXPANDED, false);
138138
aria.setRole(this.htmlDiv_!, aria.Role.TREEITEM);
139139

140-
// Ensure this group has properly set children.
141-
const selectableChildren =
142-
this.getChildToolboxItems().filter((item) => item.isSelectable()) ?? null;
143-
const focusableChildIds = selectableChildren.map(
144-
(selectable) => selectable.getFocusableElement().id,
145-
);
146-
aria.setState(
147-
this.htmlDiv_!,
148-
aria.State.OWNS,
149-
[...new Set(focusableChildIds)].join(' '),
150-
);
151-
152140
return this.htmlDiv_!;
153141
}
154142

core/toolbox/toolbox.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ export class Toolbox
369369
this.renderContents_(toolboxDef['contents']);
370370
this.position();
371371
this.handleToolboxItemResize();
372-
this.recomputeAriaOwners();
373372
}
374373

375374
/**
@@ -446,7 +445,6 @@ export class Toolbox
446445
this.addToolboxItem_(child);
447446
}
448447
}
449-
this.recomputeAriaOwners();
450448
}
451449

452450
/**
@@ -881,11 +879,6 @@ export class Toolbox
881879
this.selectedItem_ = null;
882880
this.previouslySelectedItem_ = item;
883881
item.setSelected(false);
884-
aria.setState(
885-
this.contentsDiv_ as Element,
886-
aria.State.ACTIVEDESCENDANT,
887-
'',
888-
);
889882
}
890883

891884
/**
@@ -901,11 +894,6 @@ export class Toolbox
901894
this.selectedItem_ = newItem;
902895
this.previouslySelectedItem_ = oldItem;
903896
newItem.setSelected(true);
904-
aria.setState(
905-
this.contentsDiv_ as Element,
906-
aria.State.ACTIVEDESCENDANT,
907-
newItem.getId(),
908-
);
909897
}
910898

911899
/**
@@ -1155,32 +1143,6 @@ export class Toolbox
11551143
this.autoHide(false);
11561144
}
11571145
}
1158-
1159-
/**
1160-
* Recomputes ARIA tree ownership relationships for all of this toolbox's
1161-
* categories and items.
1162-
*
1163-
* This should only be done when the toolbox's contents have changed.
1164-
*/
1165-
recomputeAriaOwners() {
1166-
const focusable = this.getFocusableElement();
1167-
const selectableChildren =
1168-
this.getToolboxItems().filter((item) => item.isSelectable()) ?? null;
1169-
const focusableChildElems = selectableChildren.map((selectable) =>
1170-
selectable.getFocusableElement(),
1171-
);
1172-
const focusableChildIds = focusableChildElems.map((elem) => elem.id);
1173-
aria.setState(
1174-
focusable,
1175-
aria.State.OWNS,
1176-
[...new Set(focusableChildIds)].join(' '),
1177-
);
1178-
// Ensure children have the correct position set.
1179-
// TODO: Fix collapsible subcategories. Their groups aren't set up correctly yet, and they aren't getting a correct accounting in top-level toolbox tree.
1180-
focusableChildElems.forEach((elem, index) =>
1181-
aria.setState(elem, aria.State.POSINSET, index + 1),
1182-
);
1183-
}
11841146
}
11851147

11861148
/** CSS for Toolbox. See css.js for use. */

0 commit comments

Comments
 (0)