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 Role: Draft Guideance #1891

Merged
merged 33 commits into from
Oct 3, 2021
Merged

Switch Role: Draft Guideance #1891

merged 33 commits into from
Oct 3, 2021

Conversation

jongund
Copy link
Contributor

@jongund jongund commented May 5, 2021

Adds a guidance section for the switch role.

Preview link for switch


Preview | Diff

@jongund jongund changed the title Draft guidance for the switch role Switch role: Draft Guideance May 6, 2021
@jongund jongund changed the title Switch role: Draft Guideance Switch Role: Draft Guideance May 6, 2021
Copy link
Contributor

@carmacleod carmacleod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @jongund !

<section class="widget" id="switch">
<h3>Switch</h3>
<p>
A <a href="#switch" class="role-reference">switch</a> is a type of checkbox that has on/off values, rather than the checked/unchecked values. There are three main patterns for using the <a href="#switch" class="role-reference">switch</a> role:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "the" for consistency with first part of sentence.

Suggested change
A <a href="#switch" class="role-reference">switch</a> is a type of checkbox that has on/off values, rather than the checked/unchecked values. There are three main patterns for using the <a href="#switch" class="role-reference">switch</a> role:
A <a href="#switch" class="role-reference">switch</a> is a type of checkbox that has on/off values, rather than checked/unchecked values. There are three main patterns for using the <a href="#switch" class="role-reference">switch</a> role:

<li>When &quot;off&quot;, it has state <a href="#aria-checked" class="state-reference" >aria-checked</a> set to <code>false</code>.
</li>
<li>When using <code>input[type=&quot;checkbox&quot;]</code> as the switch the <code>.checked</code> property should be used instead of <code>aria-checked</code> attribute, see <a href="https://www.w3.org/TR/wai-aria-1.2/#requiredState">Required States and Properties</a>.</li>
<li>If a set of switches is presented as a logical group with a visible label, the switches are included in an element with role <a href="#group" class="role-reference" >group</a> that has the property <a href="#aria-labelledby" class="property-reference" >aria-labelledby</a> set to the ID of the element containing the label or using the HTML <code>fieldset/legend</code> elements.</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence might be a bit confusing. Here's a slightly reordered version to consider:

Suggested change
<li>If a set of switches is presented as a logical group with a visible label, the switches are included in an element with role <a href="#group" class="role-reference" >group</a> that has the property <a href="#aria-labelledby" class="property-reference" >aria-labelledby</a> set to the ID of the element containing the label or using the HTML <code>fieldset/legend</code> elements.</li>
<li>If a set of switches is presented as a logical group with a visible label, the switches are either included in an HTML <code>fieldset</code> with a <code>legend</code>, or in an element with role <a href="#group" class="role-reference" >group</a> that has the property <a href="#aria-labelledby" class="property-reference" >aria-labelledby</a> set to the ID of the element containing the group label.</li>

@jongund
Copy link
Contributor Author

jongund commented May 18, 2021

@mcking65
The guidance talks about the role native semantics and ARIA properties in creating the switch. It is a simple example the illustrates what developers need to take into account about when using button and input[type=checkbox elements.

@jongund jongund requested a review from mcking65 July 15, 2021 14:35
@jongund
Copy link
Contributor Author

jongund commented Aug 3, 2021

@mcking65
Updated guidance to make the Enter key optional.

@jongund
Copy link
Contributor Author

jongund commented Aug 24, 2021

@mcking65
I updated the switch guidance to reflect the discussion in today's APG meeting.

@jongund
Copy link
Contributor Author

jongund commented Aug 26, 2021

@mcking65
Made some additional changes that I think make the feature of the switch role clearer.

@mcking65
Copy link
Contributor

@jongund
I like your clarifications based on last week's discussion. I took them a step further and tried to provide some meaningful guidance for choosing between switch and checkbox. I noticed that we even included some reference to visual presentation in the ARIA spec, so I included that in the guidance.

I'm not clear on the motivation for including implementation details in the description. We can talk about it during the meeting. My editorial preference is that we stick to our design pattern template, and like with all other patterns, rely on the examples to illustrate implementation.

@mcking65 mcking65 merged commit 71c2650 into main Oct 3, 2021
@mcking65 mcking65 deleted the switch-guidance branch October 3, 2021 05:26
@mcking65 mcking65 added this to the 1.2 Release 1 milestone Oct 3, 2021
@mcking65 mcking65 linked an issue Oct 3, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Draft switch design pattern
4 participants