From f307738ec500ad69f611d058ae15dab138664b2b Mon Sep 17 00:00:00 2001 From: Valentin Serra Date: Thu, 11 Apr 2024 15:15:40 +0200 Subject: [PATCH] chore: cleanup onChange usages Related to #1147 --- packages/form-js-playground/test/custom/viewer.js | 1 - .../src/features/repeatRender/RepeatRenderManager.js | 2 -- .../src/render/components/form-fields/Checkbox.js | 1 - .../src/render/components/form-fields/Checklist.js | 1 - .../form-js-viewer/src/render/components/form-fields/Radio.js | 1 - .../src/render/components/form-fields/Taglist.js | 4 ++-- .../src/render/components/form-fields/Textarea.js | 1 - .../src/render/components/form-fields/Textfield.js | 1 - .../render/components/form-fields/parts/SearchableSelect.js | 4 ++-- .../src/render/components/form-fields/parts/SimpleSelect.js | 4 ++-- packages/form-js-viewer/test/spec/custom/index.js | 1 - 11 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/form-js-playground/test/custom/viewer.js b/packages/form-js-playground/test/custom/viewer.js index da5febf34..1de51a1e1 100644 --- a/packages/form-js-playground/test/custom/viewer.js +++ b/packages/form-js-playground/test/custom/viewer.js @@ -21,7 +21,6 @@ function RangeRenderer(props) { const onChange = ({ target }) => { props.onChange({ - field, value: Number(target.value), }); }; diff --git a/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js b/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js index 4e0ace6bb..3211ab0a3 100644 --- a/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js +++ b/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js @@ -128,9 +128,7 @@ export class RepeatRenderManager { shouldScroll.current = true; props.onChange({ - field: repeaterField, value: updatedValues, - indexes, }); setSharedRepeatState((state) => ({ ...state, isCollapsed: false })); diff --git a/packages/form-js-viewer/src/render/components/form-fields/Checkbox.js b/packages/form-js-viewer/src/render/components/form-fields/Checkbox.js index eee3a663f..c418852a5 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Checkbox.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Checkbox.js @@ -17,7 +17,6 @@ export function Checkbox(props) { const onChange = ({ target }) => { props.onChange({ - field, value: target.checked, }); }; diff --git a/packages/form-js-viewer/src/render/components/form-fields/Checklist.js b/packages/form-js-viewer/src/render/components/form-fields/Checklist.js index 4f9f9cafa..e54f5825a 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Checklist.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Checklist.js @@ -31,7 +31,6 @@ export function Checklist(props) { : [...values, toggledValue]; props.onChange({ - field, value: newValues, }); }; diff --git a/packages/form-js-viewer/src/render/components/form-fields/Radio.js b/packages/form-js-viewer/src/render/components/form-fields/Radio.js index fc98a1f7e..c3a828f0c 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Radio.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Radio.js @@ -27,7 +27,6 @@ export function Radio(props) { const onChange = (v) => { props.onChange({ - field, value: v, }); }; diff --git a/packages/form-js-viewer/src/render/components/form-fields/Taglist.js b/packages/form-js-viewer/src/render/components/form-fields/Taglist.js index 94b6bad3c..e35907d64 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Taglist.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Taglist.js @@ -76,12 +76,12 @@ export function Taglist(props) { return; } - props.onChange({ value: [...values, value], field }); + props.onChange({ value: [...values, value] }); }; const deselectValue = (value) => { const newValues = values.filter((v) => !isEqual(v, value)); - props.onChange({ value: newValues, field }); + props.onChange({ value: newValues }); }; const onInputChange = ({ target }) => { diff --git a/packages/form-js-viewer/src/render/components/form-fields/Textarea.js b/packages/form-js-viewer/src/render/components/form-fields/Textarea.js index 5d304add9..8b4120f6b 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Textarea.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Textarea.js @@ -21,7 +21,6 @@ export function Textarea(props) { const [onChange, flushOnChange] = useFlushDebounce(({ target }) => { props.onChange({ - field, value: target.value, }); }); diff --git a/packages/form-js-viewer/src/render/components/form-fields/Textfield.js b/packages/form-js-viewer/src/render/components/form-fields/Textfield.js index d06632f20..f2cb81597 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Textfield.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Textfield.js @@ -21,7 +21,6 @@ export function Textfield(props) { const [onInputChange, flushOnChange] = useFlushDebounce(({ target }) => { props.onChange({ - field, value: target.value, }); }); diff --git a/packages/form-js-viewer/src/render/components/form-fields/parts/SearchableSelect.js b/packages/form-js-viewer/src/render/components/form-fields/parts/SearchableSelect.js index 8f1d2829c..660304897 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/parts/SearchableSelect.js +++ b/packages/form-js-viewer/src/render/components/form-fields/parts/SearchableSelect.js @@ -54,9 +54,9 @@ export function SearchableSelect(props) { const setValue = useCallback( (option) => { setFilter((option && option.label) || ''); - props.onChange({ value: (option && option.value) || null, field }); + props.onChange({ value: (option && option.value) || null }); }, - [field, props], + [props], ); const displayState = useMemo(() => { diff --git a/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js b/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js index 7b9f00126..53c7c5709 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js +++ b/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js @@ -33,9 +33,9 @@ export function SimpleSelect(props) { const setValue = useCallback( (option) => { - props.onChange({ value: (option && option.value) || null, field }); + props.onChange({ value: (option && option.value) || null }); }, - [field, props], + [props], ); const displayState = useMemo(() => { diff --git a/packages/form-js-viewer/test/spec/custom/index.js b/packages/form-js-viewer/test/spec/custom/index.js index a19d4d867..14f7c459c 100644 --- a/packages/form-js-viewer/test/spec/custom/index.js +++ b/packages/form-js-viewer/test/spec/custom/index.js @@ -41,7 +41,6 @@ function Range(props) { const onChange = ({ target }) => { props.onChange({ - field, value: Number(target.value), }); };