Skip to content

Commit 65283d6

Browse files
authored
fix(ArrayBase): remove value preparing logic, on item add call (#107)
1 parent a7a7665 commit 65283d6

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
OBJECT_ARRAY_FLAG,
1515
Spec,
1616
ValidateError,
17-
isArraySpec,
1817
isCorrectSpec,
19-
isObjectSpec,
2018
transformArrIn,
2119
} from '../../../../core';
2220
import {block} from '../../../utils';
@@ -72,19 +70,7 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => {
7270
);
7371

7472
const AddButton: React.FC = React.useCallback(() => {
75-
let onClick = () => {
76-
let item;
77-
78-
if (!spec.items?.required) {
79-
if (isArraySpec(spec.items)) {
80-
item = {[OBJECT_ARRAY_FLAG]: true, [OBJECT_ARRAY_CNT]: 0};
81-
} else if (isObjectSpec(spec.items)) {
82-
item = {};
83-
}
84-
}
85-
86-
arrayInput.onItemAdd(item);
87-
};
73+
let onClick = () => arrayInput.onItemAdd(undefined);
8874

8975
let qa = `${name}-add-item`;
9076
let title = spec.viewSpec.itemLabel;
@@ -114,10 +100,10 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => {
114100
input,
115101
name,
116102
spec.defaultValue,
117-
spec.items,
118103
spec.viewSpec.disabled,
119104
spec.viewSpec.itemLabel,
120105
spec.viewSpec.layoutTitle,
106+
spec.viewSpec.addButtonPosition,
121107
]);
122108

123109
const items = React.useMemo(

0 commit comments

Comments
 (0)