Skip to content

Commit a1147b0

Browse files
committed
a11y(raids): announce the conditional distance input via aria-live (#233)
When the user flips the location-mode radio from "Use areas" to "Set distance", the distance input appears via an `@if` block. Non-sighted users wouldn't be notified that a new field is now focusable. Wrap the `@if` in `<div aria-live="polite" aria-atomic="true">` so screen readers announce the field's appearance (and read its label) when the user toggles modes. Added a spec asserting the live region is present with the right attributes and that the distance input lands inside it after the mode switch.
1 parent a087981 commit a1147b0

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

Applications/Pgan.PoracleWebNet.App/ClientApp/src/app/shared/components/raid-delivery-section/raid-delivery-section.component.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ <h4 class="section-heading">{{ 'ALARM.LOCATION_MODE' | translate }}</h4>
2020
</mat-radio-button>
2121
</mat-radio-group>
2222

23-
@if (distanceMode().value === 'distance') {
24-
<mat-form-field appearance="outline" class="full-width">
25-
<mat-label>{{ 'ALARM.DISTANCE_LABEL' | translate }}</mat-label>
26-
<input matInput type="number" [formControl]="distanceKm()" min="0" step="0.1" />
27-
<span matSuffix>{{ 'ALARM.DISTANCE_SUFFIX' | translate }}</span>
28-
</mat-form-field>
29-
}
23+
<div aria-live="polite" aria-atomic="true">
24+
@if (distanceMode().value === 'distance') {
25+
<mat-form-field appearance="outline" class="full-width">
26+
<mat-label>{{ 'ALARM.DISTANCE_LABEL' | translate }}</mat-label>
27+
<input matInput type="number" [formControl]="distanceKm()" min="0" step="0.1" />
28+
<span matSuffix>{{ 'ALARM.DISTANCE_SUFFIX' | translate }}</span>
29+
</mat-form-field>
30+
}
31+
</div>
3032

3133
<app-delivery-preview [mode]="distanceMode().value === 'areas' ? 'areas' : 'distance'" [distanceKm]="distanceKm().value ?? 0">
3234
</app-delivery-preview>

Applications/Pgan.PoracleWebNet.App/ClientApp/src/app/shared/components/raid-delivery-section/raid-delivery-section.component.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,15 @@ describe('RaidDeliverySectionComponent', () => {
8787
component.onDistanceModeChange();
8888
expect(distanceKm.value).toBe(3);
8989
});
90+
91+
it('should wrap the conditional distance input in a polite live region', () => {
92+
fixture.detectChanges();
93+
const liveRegion: HTMLElement | null = fixture.nativeElement.querySelector('[aria-live="polite"]');
94+
expect(liveRegion).toBeTruthy();
95+
expect(liveRegion?.getAttribute('aria-atomic')).toBe('true');
96+
97+
distanceMode.setValue('distance');
98+
fixture.detectChanges();
99+
expect(liveRegion?.querySelector('input[type="number"]')).toBeTruthy();
100+
});
90101
});

0 commit comments

Comments
 (0)