mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 11:40:04 +08:00
fix: FormItem required not work without name (#21168)
This commit is contained in:
parent
048a6e28a3
commit
074fa324b6
@ -169,7 +169,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
|
|||||||
])}
|
])}
|
||||||
>
|
>
|
||||||
{/* Label */}
|
{/* Label */}
|
||||||
<FormItemLabel htmlFor={fieldId} {...props} required={isRequired} prefixCls={prefixCls} />
|
<FormItemLabel htmlFor={fieldId} required={isRequired} {...props} prefixCls={prefixCls} />
|
||||||
{/* Input Group */}
|
{/* Input Group */}
|
||||||
<FormItemInput
|
<FormItemInput
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -417,4 +417,15 @@ describe('Form', () => {
|
|||||||
);
|
);
|
||||||
expect(wrapper.find('.ant-form-item-explain').length).toBeTruthy();
|
expect(wrapper.find('.ant-form-item-explain').length).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/ant-design/ant-design/issues/21167
|
||||||
|
it('`require` without `name`', () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<Form.Item label="test" required>
|
||||||
|
<input />
|
||||||
|
</Form.Item>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper.find('.ant-form-item-required')).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user