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

Add loading prop for Button and IconButton #3582

Merged
merged 84 commits into from
Mar 21, 2024
Merged

Conversation

langermank
Copy link
Contributor

@langermank langermank commented Aug 1, 2023

Adds a loading state to both Button and IconButton. The markup follows the recommended path forward from accessibility design, and mirrors the implementation from the Export CSV button as part of GH org security coverage pages.

Implementation details

  • We use a visually hidden label instead of changing the text of the button to handle text announcements better, and to not change the size of the button.
  • aria-disabled instead of disabled to maintain focus management

New props:
loading: boolean
loadingAnnouncement: default to Loading or provide a custom message to be announced on ATs

Closes https://github.com/github/primer/issues/2680

Screenshots

CleanShot.2023-10-11.at.14.55.13.mp4
CleanShot.2023-10-11.at.14.55.42.mp4

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2023

🦋 Changeset detected

Latest commit: a7b114b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2023

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.53 KB (+1.17% 🔺)
packages/react/dist/browser.umd.js 88.76 KB (+1.17% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-3582 August 1, 2023 18:31 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 August 1, 2023 18:32 Inactive
@langermank langermank temporarily deployed to github-pages August 1, 2023 18:34 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 August 1, 2023 18:34 Inactive
@langermank langermank temporarily deployed to github-pages September 21, 2023 22:21 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 September 21, 2023 22:22 Inactive
@langermank langermank temporarily deployed to github-pages September 28, 2023 20:02 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 September 28, 2023 20:02 Inactive
@langermank langermank temporarily deployed to github-pages October 11, 2023 21:18 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 October 11, 2023 21:18 Inactive
@langermank langermank temporarily deployed to github-pages October 11, 2023 21:56 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3582 October 11, 2023 21:56 Inactive
@langermank langermank marked this pull request as ready for review October 11, 2023 21:57
@langermank langermank requested review from a team and broccolinisoup October 11, 2023 21:57
@langermank langermank changed the title [Draft] Button loading state Add loading prop for Button and IconButton Oct 11, 2023
Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

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

This has multiple approvals from other folks. Just adding my approval so I can merge.

Merging isn't blocked because of reviews, it's blocked because main is locked right now. Will merge once it's unlocked.

@mperrotti mperrotti added this pull request to the merge queue Mar 18, 2024
@joshblack joshblack removed this pull request from the merge queue due to a manual request Mar 18, 2024
@mperrotti mperrotti added this pull request to the merge queue Mar 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 19, 2024
@mperrotti mperrotti added this pull request to the merge queue Mar 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 19, 2024
@langermank langermank added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit 3be64c5 Mar 21, 2024
30 checks passed
@langermank langermank deleted the button-loading-state branch March 21, 2024 00:14
@primer primer bot mentioned this pull request Mar 21, 2024
siddharthkp added a commit that referenced this pull request Apr 4, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 4, 2024
)

* Revert "Add `loading` prop for `Button` and `IconButton` (#3582)"

This reverts commit 3be64c5.

* fix bad revert: accidentally deleted this file

* update snapshots
siddharthkp added a commit that referenced this pull request Apr 10, 2024
lukasoppermann pushed a commit that referenced this pull request Apr 16, 2024
* draft loading state

* cleanup

* add story to trigger loading

* merge

* icon button

* Create lazy-jobs-pump.md

* add prop for loading message

* handle no visuals loading state

* updates snapshots after merging from main

* uses unique ID for loading messages, preserves aria-describedby passed to button, rms aria-busy

* adds Storybook examples for btn loading error message

* reverts unintentional default link underlining

* changes loadingMessage to loadingAnnouncement

* updates draft Button component with loading prop

* updates legacy button counter behavior when loading

* Revert "updates draft Button component with loading prop"

This reverts commit 7f7f326.

* moves error behavior stories to 'Examples' section

* screenreader fixes

* adds and updates unit tests

* re-updates snapshots after using correct VisuallyHidden

* documents loading props

* adds VRTs, updates loading feature stories

* simplifies inner visual/spinner rendering logic

* removes example stories (we can put them back when Flash supports focusing its heading)

* excludes loading buttons from axe contrast check

* fixes visual regression: button counter vertical alignment

* prevents double spinners when leading and trailing visuals are passed

* test(e2e): update story ids

* test(vrt): update snapshots

* test(e2e): disable animations in screenshots

* test(vrt): update snapshots

* preserves rest state styles when button is loading

* adds story for success and error announcement

* test(vrt): update snapshots

* fixes ButtonGroup regression

* delete broken snapshots

* also targets anchor tags in ButtonGroup styles

* add conditional wrapper

* fix group

* test(vrt): update snapshots

* lint

* fixes unit tests, updates snapshots

* Update src/Button/Button.docs.json

Co-authored-by: Pavithra Kodmad <pksjce@github.com>

* fixes 'block' layout for loading buttons

* uses new internal Status component for loading announcement

* updates Tooltip V2 tests to account for loading messageID in button's aria-describedby

* fixes BoxProps type import to new preferred syntax

* appease the linter

* rms ConditionalWrapper

* revert back to using ConditionalWrapper with aria-describedby

* test(vrt): update snapshots

---------

Co-authored-by: Mike Perrotti <mperrotti@github.com>
Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
Co-authored-by: langermank <langermank@users.noreply.github.com>
Co-authored-by: Pavithra Kodmad <pksjce@github.com>
Co-authored-by: mperrotti <mperrotti@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Jul 25, 2024
…4485)

* Revert "Revert "Add `loading` prop for `Button` and `IconButton` (#3582)" (#4…"

This reverts commit c01901f.

* only overrides btn label when loading

* update tooltip tests to accomodate loading message aria-describedby

* import missing modules in IconButton stories

* makes aria-labelledby prop remain set when when button is in a loading state

* Update packages/react/src/Button/Button.examples.stories.tsx

Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>

* Update packages/react/src/Button/Button.examples.stories.tsx

Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>

* updates textinput snapshots

* addresses remaining PR feedback

* appeases the linter, updates snaps

* leaves loading prop undefined so we do not always render the wrapper

* test(vrt): update snapshots

* trying again without changing colors on faux-disabled buttons

* replaces Status with AriaStatus

* replaces one more Status with AriaStatus

* rms added aria-disabled styles

* test(vrt): update snapshots

* Update icon button tests to make it work with the loading state

* add story with leading visual and count

* misc bugfixes:
- ensures counter stays rendered even when no children are passed
- preserves space between elements that are children of span[data-component=text]
- adds story and VRT for buttons with a trailing action but no leading/trailing visuals

* test(vrt): update snapshots

---------

Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>
Co-authored-by: mperrotti <mperrotti@users.noreply.github.com>
Co-authored-by: Armagan Ersoz <broccolinisoup@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants