From 819349e925a9b20cf8304aefcebbee404829fb47 Mon Sep 17 00:00:00 2001 From: Nebojsa Date: Tue, 1 Sep 2026 11:51:42 +0200 Subject: [PATCH] fix(widgets): declare TextArea's inherited trim config unsupported 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 --- legacy/docs/content/widgets/configs/TextArea.js | 1 + packages/cx/src/widgets/form/TextArea.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/legacy/docs/content/widgets/configs/TextArea.js b/legacy/docs/content/widgets/configs/TextArea.js index f384208e8..039f9385e 100644 --- a/legacy/docs/content/widgets/configs/TextArea.js +++ b/legacy/docs/content/widgets/configs/TextArea.js @@ -7,6 +7,7 @@ export default { showClear: false, hideClear: false, inputType: false, + trim: false, reactOn: { type: 'string', description: diff --git a/packages/cx/src/widgets/form/TextArea.tsx b/packages/cx/src/widgets/form/TextArea.tsx index 06f123e24..f2feb525a 100644 --- a/packages/cx/src/widgets/form/TextArea.tsx +++ b/packages/cx/src/widgets/form/TextArea.tsx @@ -18,7 +18,11 @@ import { autoFocus } from "../autoFocus"; import { getActiveElement } from "../../util/getActiveElement"; import { NumberProp } from "../../ui/Prop"; -export interface TextAreaConfig extends TextFieldConfig { +/** + * `trim` is intentionally omitted: `TextArea` renders its own input which commits the raw value, + * so leading and trailing whitespace is always preserved. + */ +export interface TextAreaConfig extends Omit { /** Specifies the number of visible lines. */ rows?: NumberProp; @@ -65,6 +69,8 @@ export class TextArea extends TextField { TextArea.prototype.baseClass = "textarea"; TextArea.prototype.reactOn = "blur"; +// `trim` is not supported by TextArea, so a global `TextField.prototype.trim = true` must not leak into it. +TextArea.prototype.trim = false; TextArea.prototype.suppressErrorsUntilVisited = true; interface InputProps {