-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix/form toggle accessibility #909
Conversation
components/form-toggle/index.js
Outdated
</label> | ||
</div> | ||
{ showHint && | ||
<span className="components-form-toggle__hint"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #906, it seemed the recommendation would be to disable this from being read by screen readers, I presume because the input's own value state would suffice.
For this reasons, our decision was to keep using visible "on" and "off" text, hidden to assistive technologies with
aria-hidden="true"
because the state change is already announced by screen readers.
Also discussing the hint more generally at #906 (comment)
components/form-toggle/index.js
Outdated
checked, | ||
onChange = noop, | ||
showHint = true, | ||
id = 'toggle-' + this.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we need to suffix this or manipulate it in any way, or can we treat it as verbatim presumed unique from the parent passing the prop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should treat it as unique from the parent to allow its usage for the label htmlFor
without the need to "know" the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh, I missed that this was assigning the default. But why do we need a default? If the parent component isn't passing an ID, what purpose does the ID have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It's probably safe to delete.
3228a9b
to
916a98b
Compare
opacity: 0; | ||
margin: 0; | ||
padding: 0; | ||
z-index: z-index( '.components-form-toggle__input' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the need for z-index? Does it need to be higher than a dialog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is a trick to allows the onChange
handler to trigger when we click on the invisible input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh Higher than the dialog probably not. I'm updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if some logical groupings in the _z-index.scss
, even just a few comments, could help avoid this temptation of assigning it a value a little more than the next highest. Like "Relative Siblings", "Layout", "Dialogs", etc. We have some grouping already, but mostly by related components. Dunno if that's a more sustainable pattern than lower-to-highest. It's a difficult problem, and one which I don't think needs to be solved here, but I expect will continue to surface over time.
Related discussion at #637
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like the idea of grouping by "type" and inside the lowest type "relative siblings" group by related components.
4d1e195
to
619f91c
Compare
} | ||
|
||
PostStatus.instances = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a terribly complex pattern, but unfortunate in how it forces a class component. What do you think about a higher-order component for convenience?
function MyComponent( { id } ) {
return <div id={ id } />;
}
export default withUniqueId( 'prefix-' )( MyComponent );
Not to be solved here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny, because I was thinking the exact same thing 👍 (maybe uid
is better as prop or uniqueId
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe
uid
is better as prop oruniqueId
)
I don't feel strongly that it's necessary, but between the two I might prefer uniqueId
just for clarity by verbosity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of treating these components as inputs and leaving it to the developer to create the associated label. Or at least I think this helps avoid the sorts of issues observed in #906. We should start to look at how to document components as such. Code-wise I think this looks good. Still curious to see where #906's discussion goes, but with current usage not making use of the hint, I think it can be reevaluated later (or dropped now and introduced later? Not really sure its value if we choose not to use it).
…on FormToggle Includes a small fix reenabling toggling the FormToggle
Also fix the input z-index
619f91c
to
1a2c89b
Compare
This PR closes #906 by:
FormToggle
componentFormToggle
component to an inline componentlabel
from theFormToggle
componentid/for
for the input/label of the "Pending review" toggle.