fix(widgets): declare TextArea's inherited trim config unsupported - #1321
Merged
Conversation
TextArea substitutes its own Input which commits the raw value, so the inherited `trim` config was never applied even though the type surface and docs advertised it. Remove `trim` from TextAreaConfig, pin `TextArea.prototype.trim = false` so a global `TextField.prototype.trim = true` cannot leak in, and disable `trim` in the docs config alongside icon/showClear/hideClear/inputType. Closes #1320
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements option 2 from #1320.
TextAreasubstitutes its ownInput, which commits the raw value, so the inheritedtrimnever applied — while the type surface and docs advertised it.TextAreaConfig extends Omit<TextFieldConfig, "trim">—<TextArea trim />is now a compile error instead of a silent no-op.TextArea.prototype.trim = false— a globalTextField.prototype.trim = trueno longer leaks in (it would otherwise still compute an unreaddata.trim).trim: falsein the docs config, alongside the existingicon/showClear/hideClear/inputType.Behavior is unchanged: whitespace is preserved exactly as before. Note that the knock-on effect in #1320 — a whitespace-only TextArea passing
required— is inherent to option 2, not fixed by it.validateRequiredreadsstate.empty, derived from the raw input value.Related finding, not fixed here
trimisn't alone.icon,showClear,hideClear,alwaysShowClearandinputTypeare in the same state: disabled in the docs config, absent fromTextArea.tsx, inert at runtime — but still accepted by the type. All of these compile clean today and do nothing:The check is real —
<TextArea bogusProp />errors — so acceptance is a genuine claim of support.iconis the worst:Field.init()builds aFieldIconinstance thatrenderInputnever renders.Extending the
Omitto all five would make types match the docs, at the cost of newly failing compiles for currently-inert props. Left out as it's wider than #1320; happy to fold it in or open a follow-up.Verification
yarn check-typesinpackages/cxclean. Confirmed via throwaway files that<TextArea trim />now errors while<TextField trim />still compiles.