Skip to content

Commit a4aca6c

Browse files
committed
fix(progress): handle describedby like labelledby
1 parent 6fcf719 commit a4aca6c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

elements/pf-v6-progress/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ With helper text:
3737
|---|---|
3838
| `label` | Use `value-text` for custom measure text. Rich content (ReactNode) not supported. |
3939
| `tooltipPosition` | Not implemented. |
40-
| `aria-describedby` | Not supported. Use the `helper-text` slot for supplementary text. |
4140

4241
### Changed API
4342

@@ -52,6 +51,7 @@ With helper text:
5251
| `aria-label` | `accessible-label` attribute | Screen reader name only, set via ElementInternals. Falls back to `description`, then `"Progress status"`. |
5352
| `hideStatusIcon` | `hide-status-icon` attribute | Boolean. Hides the variant status icon while keeping variant coloring on the bar. |
5453
| `aria-labelledby` | `accessible-labelledby` attribute | Accepts space-separated element ID(s). Resolves cross-root `aria-labelledby` via `ariaLabelledByElements` on ElementInternals. Takes precedence over `accessible-label` and `description`. |
54+
| `aria-describedby` | `accessible-describedby` attribute | Accepts space-separated element ID(s). Resolves cross-root `aria-describedby` via `ariaDescribedByElements` on ElementInternals. |
5555

5656
### Added
5757

elements/pf-v6-progress/pf-v6-progress.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export class PfV6Progress extends LitElement {
9292
/** Space-separated ID(s) of elements that label this progress bar. Resolves cross-root aria-labelledby via ElementInternals. */
9393
@property({ attribute: 'accessible-labelledby' }) accessibleLabelledby?: string;
9494

95+
/** Space-separated ID(s) of elements that describe this progress bar. Resolves cross-root aria-describedby via ElementInternals. */
96+
@property({ attribute: 'accessible-describedby' }) accessibleDescribedby?: string;
97+
9598

9699
#internals = InternalsController.of(this, { role: 'progressbar' });
97100

@@ -136,6 +139,16 @@ export class PfV6Progress extends LitElement {
136139
this.#internals.ariaLabelledByElements = null;
137140
}
138141
}
142+
if (changed.has('accessibleDescribedby')) {
143+
if (!isServer && this.accessibleDescribedby) {
144+
const elements = this.accessibleDescribedby.trim().split(/\s+/)
145+
.map(id => document.getElementById(id))
146+
.filter((el): el is Element => el != null);
147+
this.#internals.ariaDescribedByElements = elements.length ? elements : null;
148+
} else {
149+
this.#internals.ariaDescribedByElements = null;
150+
}
151+
}
139152
if (changed.has('accessibleLabel') || changed.has('description') || !this.hasUpdated) {
140153
this.#internals.ariaLabel = this.accessibleLabel ?? this.description ?? 'Progress status';
141154
}

0 commit comments

Comments
 (0)