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

feat(react): added counter to textinput and storybook updates #12139

Merged

Conversation

TannerS
Copy link
Contributor

@TannerS TannerS commented Sep 23, 2022

Closes #

#11179

  • So the story behind this was, back a whiles, i added a counter to TextArea that got approved and merged into and released into production. Seeing how uneven / non-consistent it was having a mixture of text inputs and text areas in our microservices, i decided to add the same for textinput. This proposal got some worrisome feedback from the design team. After talking to the team in the design office hours, we decided this was ok since text area had it but in the future to possible research a better way to add a counter, although the design is based off these two issues originally and approved

#1672
#5702

but it has been said this code change should be fine

CC: @aledavila

Changelog

New

  • Added counter to TextInput to match textArea
  • Updated TextArea and TextInput Storybooks to include playground

Changed

  • Updated some wording on TextArea test

Testing / Reviewing

  • Verified in storybook and simple unit test

@TannerS TannerS requested a review from a team as a code owner September 23, 2022 04:00
Comment on lines +139 to +145
it('should not render counter with only enableCounter prop passed in', () => {
expect(
counterTestWrapper1.exists(`${prefix}--text-area__counter`)
).toEqual(false);
});

it('should not render element without only maxCount prop passed in', () => {
it('should not render counter with only maxCount prop passed in', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wording fixes

Comment on lines 90 to 96
<TextInput
{...args}
labelText="Text input label"
helperText="Optional help text"
id="text-input-1"
type="text"
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added playground storybook to test

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, thanks for adding that in @TannerS! We'll need to define the args somewhere in the storybook; take a look at FluidTextInput for an example:

Playground.argTypes = {
  placeholder: {
    control: {
      type: 'text',
    },
    defaultValue: 'Placeholder text',
  }
  ...
  ...
  ...
};

There are some props that don't apply to FluidTextInput but do to TextInput, so it may not be a complete list. I believe you can copy most of these over to the TextArea story as well

@netlify
Copy link

netlify bot commented Sep 23, 2022

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a23f35f
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/6335d5447a393b0009b268a0
😎 Deploy Preview https://deploy-preview-12139--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 23, 2022

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit a23f35f
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6335d5444c44ce0009d62c4d
😎 Deploy Preview https://deploy-preview-12139--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@TannerS TannerS requested a review from a team as a code owner September 23, 2022 04:46
@tw15egan tw15egan requested review from a team and laurenmrice and removed request for a team September 23, 2022 14:03
@tw15egan
Copy link
Collaborator

tw15egan commented Sep 23, 2022

Thanks for taking the time to contribute this, Tanner! Just had a few comments.

  • Will this counter also apply to PasswordInput?
  • Should the TextInput allow a value larger than the max, and set an invalid state? Currently, it blocks any input past the max length, including pasting
  • The args object has been added to the Playground story, but we'll need to define the controls. See the comment above
  • Should the counter align to the TextInput when the label wraps to multiple lines? If so, we should just be able to add align-items: flex-end to the label wrapper

Screen Shot 2022-09-23 at 10 25 15 AM

Everything else looks great so far 💪🏻

@TannerS
Copy link
Contributor Author

TannerS commented Sep 24, 2022

@tw15egan

Will this counter also apply to PasswordInput?
No, didn't even consider that, what you think?

Should the TextInput allow a value larger than the max, and set an invalid state? Currently, it blocks any input past the max length, including pasting

right now stopping at the limit is the current way textarea works. originally it was an idea but bouncing around the design with @abbeyhrt at the time, we thought using the native html input's/textarea's maxLength would be better than doing customized errors when going past the limit because by default the maxLength is designed to block, carbon/react isnt doing that :), if any of these wanna change, thats also a factor but would need to mirror it to textarea

Should the counter align to the TextInput when the label wraps to multiple lines? If so, we should just be able to add align-items: flex-end to the label wrapper

not sure what you mean but if you want this change ill gladly add it ;D

The args object has been added to the Playground story, but we'll need to define the controls. See the comment above

in response to this comment, #12139 (comment), ill make the change but i dont understand the change lol, playground works as is, what does the Playground.argTypes do? is it like defining all possible....props types?

thank you

@tw15egan
Copy link
Collaborator

Makes sense, if it's mirroring TextArea functionality then let's do that 👍🏻

not sure what you mean but if you want this change ill gladly add it

191983343-542914dc-f8d7-4a6a-b243-d8b101ae4f5d

Just wondering if the counter should align to the bottom of the container, cc @carbon-design-system/design

ill make the change but i dont understand the change lol, playground works as is, what does the Playground.argTypes do? is it like defining all possible....props types?

I'm seeing them all show up, but some aren't working properly. I am not able to change helperText, set a defaultValue, change the invalidText, etc.. since the argTypes aren't defined. Not a huge issue, we can always create a separate issue for this if it's out of scope

@TannerS
Copy link
Contributor Author

TannerS commented Sep 27, 2022

Makes sense, if it's mirroring TextArea functionality then let's do that 👍🏻

not sure what you mean but if you want this change ill gladly add it

191983343-542914dc-f8d7-4a6a-b243-d8b101ae4f5d

Just wondering if the counter should align to the bottom of the container, cc @carbon-design-system/design

ill make the change but i dont understand the change lol, playground works as is, what does the Playground.argTypes do? is it like defining all possible....props types?

I'm seeing them all show up, but some aren't working properly. I am not able to change helperText, set a defaultValue, change the invalidText, etc.. since the argTypes aren't defined. Not a huge issue, we can always create a separate issue for this if it's out of scope

I will do the fixes, although i may wait to hear back from @carbon-design-system/design

@TannerS
Copy link
Contributor Author

TannerS commented Sep 27, 2022

Makes sense, if it's mirroring TextArea functionality then let's do that 👍🏻

not sure what you mean but if you want this change ill gladly add it

191983343-542914dc-f8d7-4a6a-b243-d8b101ae4f5d

Just wondering if the counter should align to the bottom of the container, cc @carbon-design-system/design

ill make the change but i dont understand the change lol, playground works as is, what does the Playground.argTypes do? is it like defining all possible....props types?

I'm seeing them all show up, but some aren't working properly. I am not able to change helperText, set a defaultValue, change the invalidText, etc.. since the argTypes aren't defined. Not a huge issue, we can always create a separate issue for this if it's out of scope

For sake of examples here is both

image

image

@tw15egan please see this and the above comment, i went ahead with this change until told otherwise :D

@TannerS
Copy link
Contributor Author

TannerS commented Sep 27, 2022

Thanks for taking the time to contribute this, Tanner! Just had a few comments.

* Will this counter also apply to `PasswordInput`?

* Should the `TextInput` allow a value larger than the max, and set an invalid state? Currently, it blocks any input past the max length, including pasting

* The `args` object has been added to the `Playground` story, but we'll need to define the controls. See the comment above

* Should the counter align to the `TextInput` when the label wraps to multiple lines?  If so, we should just be able to add `align-items: flex-end` to the label wrapper
Screen Shot 2022-09-23 at 10 25 15 AM

Everything else looks great so far 💪🏻

for the latest commit, everything is done but i didnt do this to the password inout unless told too, the second point was somethign design wanted to discuss eventually but for now mirroring text area until both change

Copy link
Collaborator

@tw15egan tw15egan left a comment

Choose a reason for hiding this comment

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

LGTM 👍 ✅

Copy link
Member

@laurenmrice laurenmrice left a comment

Choose a reason for hiding this comment

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

Hi @TannerS sorry for the late review. 👋

As @tw15egan mentioned above, yes, we want to align the counter in the bottom right above the input when the label wraps to multiple lines. Also yes we want to have the same functionality for text area and text input when adding the counter for right now. I also agree we do not want to have a counter on the password variant of text input.

Eventually, the design team may look into both of these counter designs for text area/text input and do some more research and design iterations. Looks good to me!

@kodiakhq kodiakhq bot merged commit 6133193 into carbon-design-system:main Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants