Skip to content

Text input loading state - #1920

Merged
mperrotti merged 31 commits into
mainfrom
mp/text-input-loading-state
Mar 21, 2022
Merged

Text input loading state#1920
mperrotti merged 31 commits into
mainfrom
mp/text-input-loading-state

Conversation

@mperrotti

@mperrottimperrotti commented Mar 2, 2022

Copy link
Copy Markdown
Contributor

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 leadingVisualandtrailingVisual?
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 siddharthkpMarch 2, 2022 19:29
@changeset-bot

changeset-botBot commented Mar 2, 2022

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactMinor

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

github-actionsBot commented Mar 2, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js63.6 KB (+0.64% 🔺)
dist/browser.umd.js63.94 KB (+0.61% 🔺)

Comment threadsrc/TextInput.tsx Outdated
* '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
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe just loaderPosition?

Comment threadsrc/TextInput.tsx Outdated
@siddharthkp

Copy link
Copy Markdown
Member

Link to API exercise

This is the option that we all liked:

<TextInputleadingVisual={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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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.

@siddharthkpsiddharthkp left a comment

Copy link
Copy Markdown
Member

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?

Comment threaddocs/content/TextInput.mdx
Comment threaddocs/content/TextInput.mdx Outdated
@mperrottimperrotti mentioned this pull request Mar 10, 2022
6 tasks
@mperrotti

Copy link
Copy Markdown
ContributorAuthor

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?

@alliethu

Copy link
Copy Markdown

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 I believe you would still want to indicate a busy/loading status to SR users.

cc/ @primer/accessibility-reviewers

Comment threaddocs/content/TextInput.mdx Outdated
Comment threaddocs/content/TextInput.mdx Outdated
Comment threaddocs/content/TextInput.mdx Outdated
Comment threaddocs/content/TextInput.mdx Outdated
Comment threaddocs/content/TextInput.mdx Outdated
Comment threaddocs/content/TextInput.mdx Outdated
mperrottiand others added 5 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>
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
Comment threaddocs/content/TextInput.mdx Outdated

@colebemiscolebemis left a comment

Copy link
Copy Markdown
Contributor

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 mainMar 21, 2022
@mperrotti
mperrotti deleted the mp/text-input-loading-state branch March 21, 2022 19:33
@primer-cssprimer-css mentioned this pull request Mar 21, 2022
Sign up for freeto 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

@mperrotti@siddharthkp@alliethu@inkblotty@pksjce@colebemis