Skip to content

Commit

Permalink
fix(ArrayBase): remove value preparing logic, on item add call (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bocembocem authored Sep 5, 2023
1 parent a7a7665 commit 65283d6
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {
OBJECT_ARRAY_FLAG,
Spec,
ValidateError,
isArraySpec,
isCorrectSpec,
isObjectSpec,
transformArrIn,
} from '../../../../core';
import {block} from '../../../utils';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 65283d6

Please sign in to comment.