-
Notifications
You must be signed in to change notification settings - Fork 4
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): support recommendedMaxLength prop for display-only errors #1769
Conversation
TBD:
|
size-limit report 📦
|
Codecov Report
@@ Coverage Diff @@
## next #1769 +/- ##
==========================================
- Coverage 92.29% 92.29% -0.01%
==========================================
Files 146 146
Lines 2623 2635 +12
Branches 690 697 +7
==========================================
+ Hits 2421 2432 +11
Misses 187 187
- Partials 15 16 +1
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Screen.Recording.2023-09-29.at.18.14.37.mov |
bc1f6c6
to
9e43020
Compare
…ly errors - new prop allows for showing an error but letting the user continue typing content - maxLength still works, and can be a different (larger or equal) value - update snapshots - add tests
9e43020
to
9dc9bf2
Compare
function getSmallest(lengthA?: number, lengthB?: number): number | undefined { | ||
if (lengthA !== undefined && lengthB !== undefined) { | ||
return Math.min(lengthA, lengthB); | ||
} else if (lengthA && lengthB === undefined) { | ||
return lengthA; | ||
} else if (lengthB && lengthA === undefined) { | ||
return lengthB; | ||
} | ||
} |
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.
Code golf time 🏌️♀️
function getSmallest(lengthA?: number, lengthB?: number): number | undefined { | |
if (lengthA !== undefined && lengthB !== undefined) { | |
return Math.min(lengthA, lengthB); | |
} else if (lengthA && lengthB === undefined) { | |
return lengthA; | |
} else if (lengthB && lengthA === undefined) { | |
return lengthB; | |
} | |
} | |
function getSmallest(...args: Array<number | undefined>): number | undefined { | |
if (args.length === 0) { | |
return; | |
} | |
return Math.min(...args.filter(Boolean) as number[]); | |
} |
or with type predicate on the filter:
function getSmallest(lengthA?: number, lengthB?: number): number | undefined { | |
if (lengthA !== undefined && lengthB !== undefined) { | |
return Math.min(lengthA, lengthB); | |
} else if (lengthA && lengthB === undefined) { | |
return lengthA; | |
} else if (lengthB && lengthA === undefined) { | |
return lengthB; | |
} | |
} | |
function getSmallest(...args: Array<number | undefined>): number | undefined { | |
if (args.length === 0) { | |
return; | |
} | |
return Math.min(...args.filter((n): n is number => Boolean(n))); | |
} |
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.
I like these ⛳! Since the other PR builds upon this one and moves this into a utility, will commit this as-is, and take some strokes off in #1771
## [13.4.0](v13.3.0...v13.4.0) (2023-10-03) ### Features * **Accordion:** allow empty or hidden accordion rows ([#1767](#1767)) ([e044a85](e044a85)) * **Icons:** allow component icon usages to be headless ([#1761](#1761)) ([ba454bf](ba454bf)) * **InputField:** support recommendedMaxLength prop for display-only errors ([#1771](#1771)) ([cc84a20](cc84a20)) * **Tabs:** add ability to customize tab button headers ([#1768](#1768)) ([f231ad4](f231ad4)) * **TextareaField:** support recommendedMaxLength prop for display-only errors ([#1769](#1769)) ([0852356](0852356))
Summary:
recommendedLength
allows for showing an error but letting the user continue typing contentmaxLength
still works, and can be a different (larger or equal) valueTest Plan:
edu-stack
ortraject
as a sanity check if changes affect build or deploy, or are breaking, such as token changes, widely used component updates, hooks changes, and major dependency upgrades.