Skip to content

Text input loading state #1920

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

Merged
merged 31 commits into from
Mar 21, 2022
Merged

Text input loading state #1920

merged 31 commits into from
Mar 21, 2022

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Mar 2, 2022

Issue: https://github.com/github/primer/issues/156

Adds a loading state to the text input. The loading indicator is positioned to avoid layout shifts in the component when it hides and shows.

loadingIndicatorPosition="auto" (default behavior)

Does not have a leadingVisual OR trailingVisual?
Show at the end of the input

Has a leadingVisual?
Show in place of the leadingVisual

Has a trailingVisual?
Show in place of the trailingVisual

Has a leadingVisual and trailingVisual?
Show in place of the trailingVisual

Does not have a leadingVisual?
Show at the end of the input

loadingIndicatorPosition="leading"

Show in place of leadingVisual if there is one, or show at the start of the input

loadingIndicatorPosition="trailing"

Show in place of trailingVisual if there is one, or show at the end of the input

Screenshots

TextInputLoadingDemo

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • 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.

@mperrotti mperrotti requested review from a team and siddharthkp March 2, 2022 19:29
@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2022

🦋 Changeset detected

Latest commit: f9ad318

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 Mar 2, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 63.6 KB (+0.64% 🔺)
dist/browser.umd.js 63.94 KB (+0.61% 🔺)

* 'leading': at the beginning of the input
* 'trailing': at the end of the input
**/
loadingIndicatorPosition?: 'auto' | 'leading' | 'trailing' // TODO: come up with a shorter name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any better recommendations for this prop name? It's so long...

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just loaderPosition?

@siddharthkp
Copy link
Member

Link to API exercise

This is the option that we all liked:

<TextInput 
  leadingVisual={MergeIcon}
  trailingVisual={CheckIcon}
  isLoading={true | false}
  loaderPosition="auto | leading | trailing" 
/>

@@ -0,0 +1,45 @@
import React from 'react'
import {Box, Spinner} from '.'
import {TextInputNonPassthroughProps} from './TextInput'
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think this is like a circular dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly, but it's just a type. Do you have any alternative suggestions?

import {Box, Spinner} from '.'
import {TextInputNonPassthroughProps} from './TextInput'

const TextInputInnerVisualSlot: React.FC<{
Copy link
Contributor

Choose a reason for hiding this comment

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

is it more like TextInputReplaceLoader or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still feel like it's more about the visual than the loader.

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

This is looking good! Left a few suggestions for the docs

What is the accessibility story for loading state? Does it need to be announced? Do we need to change the aria-describedby in FormControl?

@mperrotti mperrotti mentioned this pull request Mar 10, 2022
6 tasks
@mperrotti
Copy link
Contributor Author

What is the accessibility story for loading state? Does it need to be announced? Do we need to change the aria-describedby in FormControl?

I don't think we need to announce it, but I could be wrong. @alliethu - any input on this?

mperrotti and others added 2 commits March 21, 2022 14:21
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
mperrotti and others added 2 commits March 21, 2022 14:22
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
Copy link
Contributor

@colebemis colebemis 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! Left a few comments about docs but nothing blocking

@mperrotti mperrotti merged commit 40ed423 into main Mar 21, 2022
@mperrotti mperrotti deleted the mp/text-input-loading-state branch March 21, 2022 19:33
@primer-css primer-css mentioned this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants