mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
fix: Form.Item with name 0
should be validate (#21179)
* fix FormItem missing name * update test case
This commit is contained in:
parent
92998e67ef
commit
207fc03c91
@ -189,7 +189,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
|
|||||||
|
|
||||||
const isRenderProps = typeof children === 'function';
|
const isRenderProps = typeof children === 'function';
|
||||||
|
|
||||||
if (!name && !isRenderProps && !dependencies) {
|
if (name === undefined && !isRenderProps && !dependencies) {
|
||||||
return renderLayout(children as ChildrenNodeType);
|
return renderLayout(children as ChildrenNodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,4 +428,14 @@ describe('Form', () => {
|
|||||||
|
|
||||||
expect(wrapper.find('.ant-form-item-required')).toHaveLength(1);
|
expect(wrapper.find('.ant-form-item-required')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('0 is a validate Field', () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<Form.Item name={0}>
|
||||||
|
<input />
|
||||||
|
</Form.Item>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper.find('Field')).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user