Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch: Set aria-checked value to "true" and "false" #2450

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ describe('modus-switch', () => {
const input = await page.find('modus-switch >>> input');
expect(await modusSwitch.getProperty('checked')).toBeTruthy();
expect(await input.getProperty('checked')).toBeTruthy();
expect(await input.getAttribute('aria-checked').toLowerCase()).toEqual('true');

await element.click();
await page.waitForChanges();

expect(await modusSwitch.getProperty('checked')).toBeFalsy();
expect(await input.getProperty('checked')).toBeFalsy();
expect(await input.getAttribute('aria-checked').toLowerCase()).toEqual('false');
});
it('renders with medium size', async () => {
const page = await newE2EPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('modus-switch', () => {
<div class="switch">
<span class="slider"></span>
</div>
<input role="switch" type="checkbox">
<input aria-checked="false" role="switch" type="checkbox">
</div>
</mock:shadow-root>
</modus-switch>
Expand All @@ -33,7 +33,7 @@ describe('modus-switch', () => {
<div class="switch">
<span class="slider"></span>
</div>
<input role="switch" aria-disabled="true" disabled type="checkbox">
<input aria-checked="false" role="switch" aria-disabled="true" disabled type="checkbox">
</div>
</mock:shadow-root>
</modus-switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ModusSwitch {
@Prop() ariaLabel: string | null;

/** (optional) Whether the switch is checked. */
@Prop({ mutable: true }) checked: boolean;
@Prop({ mutable: true }) checked = false;

/** (optional) Whether the switch is disabled. */
@Prop() disabled: boolean;
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ModusSwitch {
<span class={`slider`}></span>
</div>
<input
aria-checked={this.checked}
aria-checked={String(this.checked)}
aria-disabled={this.disabled ? 'true' : undefined}
aria-label={this.ariaLabel}
checked={this.checked}
Expand Down
Loading