Browse Source

fix: FormItem required not work without name (#21168)

pull/21169/head
二货机器人 5 years ago
committed by GitHub
parent
commit
074fa324b6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/form/FormItem.tsx
  2. 11
      components/form/__tests__/index.test.js

2
components/form/FormItem.tsx

@ -169,7 +169,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
])}
>
{/* Label */}
<FormItemLabel htmlFor={fieldId} {...props} required={isRequired} prefixCls={prefixCls} />
<FormItemLabel htmlFor={fieldId} required={isRequired} {...props} prefixCls={prefixCls} />
{/* Input Group */}
<FormItemInput
{...props}

11
components/form/__tests__/index.test.js

@ -417,4 +417,15 @@ describe('Form', () => {
);
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…
Cancel
Save