-
Notifications
You must be signed in to change notification settings - Fork 506
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
Un-revert "Add loading
prop for Button
and IconButton
(#3582)"
#4485
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 4fce38a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
loading
prop for Button
and IconButton
(#3582)""loading
prop for Button
and IconButton
(#3582)"
size-limit report 📦
|
Hi! There is another bug when aria-label is present, tried to address that in this PR (not merged): #4459 Should I copy those changes over here as well? |
@siddharthkp - yes, please copy those changes over as well |
Sorry, while copying over my changes, I ran into a couple questions On this line: https://github.com/primer/react/pull/4485/files#diff-515525e4a59d9a55e13c6c60155ec6782c78a026aae4c540c324cd8e11c83a48R102-R105,
Looking at this comment, is this still true? It looks like we set |
@siddharthkp I'm not sure I understand your question because we set all three depending on the situation. We set We set
We set
|
Sorry, bad choice of words from me. I'll try again Looking at this block of code: https://github.com/primer/react/pull/4485/files#diff-515525e4a59d9a55e13c6c60155ec6782c78a026aae4c540c324cd8e11c83a48R102-R105: // aria-labelledby is needed because the accessible name becomes unset when the button is in a loading state.
// We only set it when the button is in a loading state because it will supercede the aria-label when the screen
// reader announces the button name.
aria-labelledby={loading ? `${uuid}-label` : ariaLabelledBy} and wondering why/when accessible name becomes unset when the button is in a loading state? I removed it that line and saw no changes which really confused me. I'm probably missing something very obvious here, thanks for your patience with me! |
Thanks @siddharthkp
I had the same experience in the browser, but it caused the following test to fail:
|
Oh that's rough! Ideally, I'd like to optimise it for the browser and fix/workaround the jest error. UNLESS, we also see similar jest errors in dotcom integration tests? cc @joshblack @broccolinisoup @pksjce (nerd sniping 🤭) have you seen something like this before? |
It looks like when the button is in a loading state, the text is visually hidden via I'm thinking that there are only a few options here, one being the current pattern using the |
// aria-labelledby is needed because the accessible name becomes unset when the button is in a loading state. | ||
// We only set it when the button is in a loading state because it will supercede the aria-label when the screen | ||
// reader announces the button name. | ||
aria-labelledby={loading ? `${uuid}-label` : ariaLabelledBy} |
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 we could add ariaLabelledBy
to the first condition too?
(i.e. ${uuid}-label ${ariaLabelledBy}
: ariaLabelledBy
)
This allows instances that rely on aria-labelledby
to remain covered, even if the button is in a loading state.
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 I didn't realize we could have 2 values in aria-labelledby. That could work! I'll give it a try...
We have a component for that: https://github.com/primer/react/blob/main/packages/react/src/internal/components/VisuallyHidden.tsx |
@siddharthkp - do you think @TylerJDev 's suggestion will fix our problem? |
I believe the problem would still persist here if there's no
This would actually be a good alternative! We wouldn't need to reference the inner span anymore if we used this, and it should be visually equivalent to |
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.
Took a look because I am looking at an adjacent topic of buttons with dynamically updated labels! :)
return ( | ||
<> | ||
<VisuallyHidden aria-live="polite">{!loading && success ? 'Export completed' : null}</VisuallyHidden> | ||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> |
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.
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> | |
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('success')}> |
Should this be success
? I noticed that the live region doesn't get updated with the Export completed
announcement in the storybook success example.
It seems to be getting updated for the error example though!
) | ||
} | ||
|
||
export const LoadingStatusAnnouncementError = () => { |
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.
In this example, the failure state is communicated to assistive technologies via announcement, but there's no visual indication that anything failed.
Do we have guidance around communicating errors visually? If so, should this example include that?
|
||
return ( | ||
<> | ||
<VisuallyHidden aria-live="polite">{!loading && error ? 'Export failed' : null}</VisuallyHidden> |
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 the announcement utility components be used in these examples instead, or are they only recommended for use internally? (cc: @joshblack)
<VisuallyHidden aria-live="polite">{!loading && error ? 'Export failed' : null}</VisuallyHidden> | |
<VisuallyHidden><Status>{!loading && error ? 'Export failed' : null}</Status></VisuallyHidden> |
|
||
export default meta | ||
|
||
export const LoadingStatusAnnouncementSuccessful = () => { |
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.
In these examples, when the loading state is activated, the focus gets lost and removed from the button. I believe this is a 2.4.3 issue, and may result in some screen reader users ending up at the top of the page. Could we avoid focus loss?
@mperrotti is there anything the a11y v-team can help with to get this PR along the finish line? |
Brings back #3582