Skip to content

Commit

Permalink
fix: (CXSPA-7948) add aria-labelledby to quantity input (#19312)
Browse files Browse the repository at this point in the history
Co-authored-by: Miguel Estrada <[email protected]>
  • Loading branch information
StanislavSukhanov and developpeurweb authored Oct 17, 2024
1 parent 313ba61 commit e9a1c2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*ngIf="hasStock"
[max]="maxQuantity"
[control]="addToCartForm.get('quantity')"
[ariaDescribedById]="'add-to-card-stock-info'"
></cx-item-counter>

<span class="info">
<span class="info" id="add-to-card-stock-info">
<span *ngIf="showInventory$ | async">{{ getInventory() }}</span>
{{
hasStock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
(keyup.enter)="updateValue()"
[cxFocus]="{ key: 'qty' }"
attr.aria-label="{{ 'itemCounter.quantity' | cxTranslate }}"
[attr.aria-describedby]="ariaDescribedById"
/>
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export class ItemCounterComponent implements OnInit, OnDestroy {
*/
@Input() allowZero = false;

/**
* ID of the element associated with the number input,
* so it gets narrated by a screen reader
*/
@Input() ariaDescribedById: string = '';

/**
* In readonly mode the item counter will only be shown as a label,
* the form controls are not rendered.
Expand Down

0 comments on commit e9a1c2e

Please sign in to comment.