fix: Use field ARIA labels for field-only blocks. (#9361)

* fix: Use field ARIA labels for field-only blocks.

* chore: Make the linter happy.
This commit is contained in:
Aaron Dodson
2025-09-12 14:25:33 -07:00
committed by GitHub
parent b10f1af655
commit f682607a6c

View File

@@ -224,9 +224,6 @@ export class BlockSvg
this.currentConnectionCandidate = null;
this.doInit_();
// Note: This must be done after initialization of the block's fields.
this.recomputeAriaLabel();
}
private recomputeAriaLabel() {
@@ -239,15 +236,19 @@ export class BlockSvg
private computeAriaLabel(): string {
// Guess the block's aria label based on its field labels.
if (this.isShadow()) {
if (this.isShadow() || this.isSimpleReporter()) {
// TODO: Shadows may have more than one field.
// Shadow blocks are best represented directly by their field since they
// effectively operate like a field does for keyboard navigation purposes.
const field = Array.from(this.getFields())[0];
return (
aria.getState(field.getFocusableElement(), aria.State.LABEL) ??
'Unknown?'
);
try {
return (
aria.getState(field.getFocusableElement(), aria.State.LABEL) ??
'Unknown?'
);
} catch {
return 'Unknown?';
}
}
const fieldLabels = [];
@@ -306,6 +307,8 @@ export class BlockSvg
if (!svg.parentNode) {
this.workspace.getCanvas().appendChild(svg);
}
// Note: This must be done after initialization of the block's fields.
this.recomputeAriaLabel();
this.initialized = true;
}