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(TextareaField): add character length counter #1580

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

booc0mtaco
Copy link
Contributor

Summary:

  • only shows up if max length is specified
  • turns red if the default value is greater than allowed
  • updates as you type
  • currently no warning color as you approach limit
  • by default textareas do not allow entry above maxlength
  • but you can delete if somehow above maxlength
  • field not in error state when above max length

Test Plan:

  • Wrote automated tests
  • CI tests / new tests are not applicable
  • Manually tested my changes, but I want to keep the details secret
  • Manually tested my changes, and here are the details:
    • review snapshot / chromatic changes

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

size-limit report 📦

Path Size
components 118.96 KB (+0.25% 🔺)
styles 3.12 KB (0%)

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #1580 (dab979f) into next (b581814) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             next    #1580      +/-   ##
==========================================
+ Coverage   91.63%   91.69%   +0.06%     
==========================================
  Files         279      279              
  Lines        4267     4289      +22     
  Branches      776      786      +10     
==========================================
+ Hits         3910     3933      +23     
+ Misses        331      330       -1     
  Partials       26       26              
Impacted Files Coverage Δ
...components/TextareaField/TextareaField.stories.tsx 100.00% <100.00%> (ø)
src/components/TextareaField/TextareaField.tsx 100.00% <100.00%> (+3.33%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@booc0mtaco booc0mtaco force-pushed the aholloway/EDS-846 branch 4 times, most recently from 39c62f9 to e066606 Compare April 4, 2023 16:21
@booc0mtaco booc0mtaco requested a review from a team April 4, 2023 16:25
@ghost
Copy link

ghost commented Apr 4, 2023

I don't see a story that includes the character count, would it be worth capturing that state?

@booc0mtaco
Copy link
Contributor Author

booc0mtaco commented Apr 4, 2023

I don't see a story that includes the character count, would it be worth capturing that state?

@jeremiah-clothier We apply character count when there's a maxlength specified, so stories like this one will do the trick

@ghost
Copy link

ghost commented Apr 4, 2023

I don't see a story that includes the character count, would it be worth capturing that state?

@jeremiah-clothier We apply character count when there's a maxlength specified, so stories like this one will do the trick

Oh, I guess I was looking at the wrong chromatic build. I didn't realize their had been a few for the PR and the stories with that character limit displayed were already accepted

Copy link
Contributor

@jinlee93 jinlee93 left a comment

Choose a reason for hiding this comment

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

Any thoughts on having character count validation either as a recipe or a wrapping component to also be used on InputField?

@booc0mtaco
Copy link
Contributor Author

@jinlee93 having the counter exist as a separate composable component isn't a bad idea. We can confer with design if any other fields like InputField could use this. I'm inclined to keep it as an integral part of TextareaField for now, since that's the only place in Figma that it lives currently.

@jinlee93
Copy link
Contributor

jinlee93 commented Apr 4, 2023

@jinlee93 having the counter exist as a separate composable component isn't a bad idea. We can confer with design if any other fields like InputField could use this. I'm inclined to keep it as an integral part of TextareaField for now, since that's the only place in Figma that it lives currently.

Makes sense to me, thanks

- only shows up if max length is specified
- turns red if the default value is greater than allowed
- updates as you type
- currently no warning color as you approach limit
- by default textareas do not allow entry above maxlength
- but you can delete if somehow above maxlength
- handle custom onChange events
@booc0mtaco booc0mtaco merged commit ff6226f into next Apr 4, 2023
@booc0mtaco booc0mtaco deleted the aholloway/EDS-846 branch April 4, 2023 21:07
@booc0mtaco booc0mtaco mentioned this pull request Apr 17, 2023
booc0mtaco added a commit that referenced this pull request Apr 17, 2023
## [12.0.0](v11.1.1...v12.0.0) (2023-04-17)


### ⚠ BREAKING CHANGES

* use rollup (#1555)

### Features

* export some subcomponents ([#1579](#1579)) ([2857ae4](2857ae4))
* **TextareaField:** add character length counter ([#1580](#1580)) ([ff6226f](ff6226f))


### Bug Fixes

* restore check for undefined any types ([#1585](#1585)) ([c7fae07](c7fae07))
* **Skeleton:** mark .Rect as deprecated ([#1586](#1586)) ([405f81b](405f81b))
* sync typography presets to documentation ([#1592](#1592)) ([b56eadb](b56eadb))
* **typography:** add missing eds-font-size-20 ([#1591](#1591)) ([de5dd03](de5dd03))


### build

* use rollup ([#1555](#1555)) ([d794696](d794696)), closes [#1558](#1558) [#1572](#1572) [#1581](#1581) [#1582](#1582)
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.

2 participants