Skip to content

Commit

Permalink
Radio: add aria-describedby association for validation messages (#824)
Browse files Browse the repository at this point in the history
* fix(radio): add aria-describedby association for message

* chore: add changeset
  • Loading branch information
sirrah-tam authored Oct 23, 2024
1 parent aec1ef4 commit 0717dd8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-cherries-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ithaka/pharos': minor
---

Radio buttons: Add aria-describedby association for validation message
Binary file modified .yarn/install-state.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ describe('pharos-radio-button', () => {
await expect(component).to.be.accessible();
});

it('has association with validation message', async () => {
component = await fixture(html`
<test-pharos-radio-button message="this is a test"
><span slot="label">test radio</span></test-pharos-radio-button
>
`);
await expect(
component.renderRoot.querySelector('input')?.getAttribute('aria-describedby')
).to.equal('message');
});

it('has an attribute to set check value', async () => {
component = await fixture(html`
<test-pharos-radio-button checked
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { html } from 'lit';
import { property, query } from 'lit/decorators.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import type { TemplateResult, CSSResultArray } from 'lit';
import { radioButtonStyles } from './pharos-radio-button.css';
import { FormElement } from '../base/form-element';
Expand All @@ -13,6 +14,7 @@ const LINKS = `a[href],pharos-link[href],[data-pharos-component='PharosLink'][hr
* @tag pharos-radio-button
*
* @slot label - Contains the label content.
* @slot message - Contains message content to show below the input.
*
* @fires change - Fires when the value has changed
*/
Expand Down Expand Up @@ -84,6 +86,7 @@ export class PharosRadioButton extends FormMixin(FormElement) {
?required="${this.required}"
?disabled=${this.disabled}
@change=${this.onChange}
aria-describedby="${ifDefined(this.messageId)}"
/>
<div class="input-wrapper">
<svg
Expand Down

0 comments on commit 0717dd8

Please sign in to comment.