-
Notifications
You must be signed in to change notification settings - Fork 77
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(text-area): add support for minLength
#10970
base: dev
Are you sure you want to change the base?
feat(text-area): add support for minLength
#10970
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great @Elijbet! 🌮
Just a few minor suggestions.
packages/calcite-components/src/components/text-area/assets/t9n/messages.json
Outdated
Show resolved
Hide resolved
packages/calcite-components/src/components/text-area/resources.ts
Outdated
Show resolved
Hide resolved
packages/calcite-components/src/components/text-area/text-area.tsx
Outdated
Show resolved
Hide resolved
packages/calcite-components/src/components/text-area/assets/t9n/messages.json
Show resolved
Hide resolved
minlength
to text-area
minLength
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few comments, but this looks great, @Elijbet!
Can you also add a screenshot test? We can tweak the Exceeding Max Length Test Only
story to include both min and max tests (along with proper rename).
packages/calcite-components/src/components/text-area/text-area.tsx
Outdated
Show resolved
Hide resolved
packages/calcite-components/src/components/text-area/text-area.tsx
Outdated
Show resolved
Hide resolved
packages/calcite-components/src/components/text-area/text-area.e2e.ts
Outdated
Show resolved
Hide resolved
… replacing long and short messages
return result; | ||
} | ||
|
||
private replacePlaceholdersInLongMessages(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can we use a different name here to be more meaningful.
replaceMaxLengthPlaceHolderMessage( )
or getMaxLengthMessage( )
.
} | ||
|
||
private isCharacterLimitExceeded(): boolean { | ||
private replacePlaceholdersInShortMessages(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can we use a different name here to be more meaningful.
replaceMinLengthPlaceHolderMessage( ) or getMinLengthMessage( ).
return this.messages.tooLong | ||
.replace("{maxLength}", this.localizedCharacterLengthObj.maxLength) | ||
.replace("{currentLength}", this.localizedCharacterLengthObj.currentLength); | ||
private replacePlaceholders( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can we retain the name replacePlaceholdersInMessages()
. Helps providing context of placeHolders and avoid confusing with place-holder
property of text-area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great ! 🏆
Recommend a11y review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -1,4 +1,5 @@ | |||
{ | |||
"invalid": "Invalid", | |||
"tooLong": "The current character length is {currentLength}, which exceeds the maximum character length of {maxLength}." | |||
"tooLong": "The current character length is {currentLength}, which exceeds the maximum character length of {maxLength}.", | |||
"tooShort": "The current character length is {currentLength}, which is less than the minimum character length of {minLength}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refrain from using this message string in component code while translations are pending to avoid errors for non-en locales.
Currently, we don't provide fallback values for new strings added in existing bundles. Fallback is used only for new components/ new bundles.
Once translations are back one can access the this.messages.tooShort
prop in component.
cc @jcfranco
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anveshmekala Can you create an issue for us to explore an option for us to use messages regardless of translation status?
This PR is blocked due to #8626 (comment). It can still be partially adopted once element internals work is in. |
Related Issue: #8626
Summary
Add support for
minlength
totext-area
.