From 65283d68f55a489945b5014daa2d6c2ac3cf23eb Mon Sep 17 00:00:00 2001 From: Nikita Zolotykh <58661343+bocembocem@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:53:42 +0200 Subject: [PATCH] fix(ArrayBase): remove value preparing logic, on item add call (#107) --- .../components/Inputs/ArrayBase/ArrayBase.tsx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx b/src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx index 4a9e75dc..ab51b056 100644 --- a/src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx +++ b/src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx @@ -14,9 +14,7 @@ import { OBJECT_ARRAY_FLAG, Spec, ValidateError, - isArraySpec, isCorrectSpec, - isObjectSpec, transformArrIn, } from '../../../../core'; import {block} from '../../../utils'; @@ -72,19 +70,7 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => { ); const AddButton: React.FC = React.useCallback(() => { - let onClick = () => { - let item; - - if (!spec.items?.required) { - if (isArraySpec(spec.items)) { - item = {[OBJECT_ARRAY_FLAG]: true, [OBJECT_ARRAY_CNT]: 0}; - } else if (isObjectSpec(spec.items)) { - item = {}; - } - } - - arrayInput.onItemAdd(item); - }; + let onClick = () => arrayInput.onItemAdd(undefined); let qa = `${name}-add-item`; let title = spec.viewSpec.itemLabel; @@ -114,10 +100,10 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => { input, name, spec.defaultValue, - spec.items, spec.viewSpec.disabled, spec.viewSpec.itemLabel, spec.viewSpec.layoutTitle, + spec.viewSpec.addButtonPosition, ]); const items = React.useMemo(