mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +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';
|
||||
|
||||
if (!name && !isRenderProps && !dependencies) {
|
||||
if (name === undefined && !isRenderProps && !dependencies) {
|
||||
return renderLayout(children as ChildrenNodeType);
|
||||
}
|
||||
|
||||
|
@ -428,4 +428,14 @@ describe('Form', () => {
|
||||
|
||||
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