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 {