Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Un-revert "Add loading prop for Button and IconButton (#3582)"#4485
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
60b32530c29ea727a7c5814c0278ac0801b708f452e765c0522ea550b881fd7ccde61a33995014fce38ac454b3e29e59552e1df4486b14e7852c9e2f7616c9f9cdfb51ee58542749e5244845b3b3f90ed59d90c6f61d1d695843eb73cf0683d2f91778e99a39007105e9e391ad4017828cb483050cfa75be9446776724c7a7741baabbd4d8f379211c1b40a2093a8bd50eb950a400ed9abd687085d8358691bb7a85c68a6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@primer/react": minor | ||
| --- | ||
| Add `loading` state to `Button` and `IconButton` |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import React from 'react' | ||
| import type {Meta} from '@storybook/react' | ||
| import {Button} from '.' | ||
| import {DownloadIcon} from '@primer/octicons-react' | ||
| import {Banner} from '../drafts' | ||
| import {AriaStatus} from '../live-region' | ||
| const meta: Meta<typeof Button> = { | ||
| title: 'Components/Button/Examples', | ||
| } as Meta<typeof Button> | ||
| export default meta | ||
| export const LoadingStatusAnnouncementSuccessful = () => { | ||
| const [loading, setLoading] = React.useState(false) | ||
| const [success, setSuccess] = React.useState(false) | ||
| const resolveAction = async () => { | ||
| setLoading(true) | ||
| await new Promise(resolve => setTimeout(resolve, 1500)) | ||
| setLoading(false) | ||
| return await true | ||
| } | ||
| const onClick = (resolveType: 'error' | 'success') => async () => { | ||
| const actionResult = await resolveAction() | ||
| if (resolveType === 'error') { | ||
| setSuccess(!actionResult) | ||
| return | ||
| } | ||
| setSuccess(actionResult) | ||
| } | ||
| return ( | ||
| <> | ||
| <AriaStatus>{!loading && success ? 'Export completed' : null}</AriaStatus> | ||
| <Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('success')}> | ||
| Export (success) | ||
| </Button> | ||
| </> | ||
| ) | ||
| } | ||
| export const LoadingStatusAnnouncementError = () => { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great point! I'll take a look through our docs and update this. | ||
| const [loading, setLoading] = React.useState(false) | ||
| const [error, setError] = React.useState(false) | ||
| const resolveAction = async () => { | ||
| setLoading(true) | ||
| await new Promise(resolve => setTimeout(resolve, 1500)) | ||
| setLoading(false) | ||
| return await true | ||
| } | ||
| const onClick = (resolveType: 'error' | 'success') => async () => { | ||
| const actionResult = await resolveAction() | ||
| if (resolveType === 'error') { | ||
| setError(actionResult) | ||
| return | ||
| } | ||
| setError(!actionResult) | ||
| } | ||
| return ( | ||
| <> | ||
| {!loading && error ? <Banner title="Export failed" variant="critical" /> : null} | ||
| <Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> | ||
| Export (error) | ||
| </Button> | ||
| </> | ||
| ) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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?
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.
Good catch. I'll take a look.