Skip to content

Commit 7b72c03

Browse files
committed
fix: list nest list
1 parent d1d5e2f commit 7b72c03

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Field.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
627627
function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>) {
628628
const fieldContext = React.useContext(FieldContext);
629629
const listContext = React.useContext(ListContext);
630-
const mergedIsListField = restProps.isListField || (!restProps.isList && !!listContext);
631630
const namePath = name !== undefined ? getNamePath(name) : undefined;
632631

633632
let key: string = 'keep';
@@ -650,7 +649,7 @@ function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>)
650649
<Field
651650
key={key}
652651
name={namePath}
653-
isListField={mergedIsListField}
652+
isListField={!!listContext}
654653
{...restProps}
655654
fieldContext={fieldContext}
656655
/>

src/List.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const List: React.FunctionComponent<ListProps> = ({
4343
isListField,
4444
}) => {
4545
const context = React.useContext(FieldContext);
46+
const wrapperListContext = React.useContext(ListContext);
4647
const keyRef = React.useRef({
4748
keys: [],
4849
id: 0,
@@ -91,7 +92,7 @@ const List: React.FunctionComponent<ListProps> = ({
9192
validateTrigger={validateTrigger}
9293
initialValue={initialValue}
9394
isList
94-
isListField={isListField}
95+
isListField={isListField ?? !!wrapperListContext}
9596
>
9697
{({ value = [], onChange }, meta) => {
9798
const { getFieldValue } = context;

0 commit comments

Comments
 (0)