From eb201ace680785704e556848d96ce5e0599894f8 Mon Sep 17 00:00:00 2001 From: hbhong Date: Tue, 30 Apr 2024 09:43:52 +0800 Subject: [PATCH] fix(TDC-7476/form): check onFinish and onChange before invoking for the Text component (#5297) --- .changeset/dirty-elephants-dream.md | 5 +++++ .../forms/src/UIForm/fields/Text/Text.component.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/dirty-elephants-dream.md diff --git a/.changeset/dirty-elephants-dream.md b/.changeset/dirty-elephants-dream.md new file mode 100644 index 00000000000..69886caee6d --- /dev/null +++ b/.changeset/dirty-elephants-dream.md @@ -0,0 +1,5 @@ +--- +"@talend/react-forms": patch +--- + +fix: check onFinish and onChange before invoking for the Text component diff --git a/packages/forms/src/UIForm/fields/Text/Text.component.js b/packages/forms/src/UIForm/fields/Text/Text.component.js index 9e2b36bc1e8..333d442fcb2 100644 --- a/packages/forms/src/UIForm/fields/Text/Text.component.js +++ b/packages/forms/src/UIForm/fields/Text/Text.component.js @@ -36,8 +36,16 @@ export default function Text(props) { autoComplete, autoFocus, disabled: disabled || valueIsUpdating, - onBlur: event => onFinish(event, { schema }), - onChange: event => onChange(event, { schema, value: convertValue(type, event.target.value) }), + onBlur: event => { + if (onFinish) { + onFinish(event, { schema }); + } + }, + onChange: event => { + if (onChange) { + onChange(event, { schema, value: convertValue(type, event.target.value) }); + } + }, placeholder, readOnly, type,