Browse Source
fix: Form.Item shaking when `help` is empty string (#33644)
* fix: empty help takes the line
* test: test case
pull/33661/head
二货机器人
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
25 additions and
10 deletions
-
components/form/FormItem.tsx
-
components/form/__tests__/index.test.js
|
|
@ -224,7 +224,8 @@ function FormItem<Values = any>(props: FormItemProps<Values>): React.ReactElemen |
|
|
|
|
|
|
|
const itemClassName = { |
|
|
|
[`${prefixCls}-item`]: true, |
|
|
|
[`${prefixCls}-item-with-help`]: help || debounceErrors.length || debounceWarnings.length, |
|
|
|
[`${prefixCls}-item-with-help`]: |
|
|
|
(help !== undefined && help !== null) || debounceErrors.length || debounceWarnings.length, |
|
|
|
[`${className}`]: !!className, |
|
|
|
|
|
|
|
// Status
|
|
|
|
|
|
@ -315,7 +315,8 @@ describe('Form', () => { |
|
|
|
expect(wrapper.find('.ant-form-item-required')).toHaveLength(1); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should show related className when customize help', () => { |
|
|
|
describe('should show related className when customize help', () => { |
|
|
|
it('normal', () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Form> |
|
|
|
<Form.Item help="good"> |
|
|
@ -324,7 +325,20 @@ describe('Form', () => { |
|
|
|
</Form>, |
|
|
|
); |
|
|
|
|
|
|
|
expect(wrapper.find('.ant-form-item-with-help').length).toBeTruthy(); |
|
|
|
expect(wrapper.exists('.ant-form-item-with-help')).toBeTruthy(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('empty string', () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Form> |
|
|
|
<Form.Item help=""> |
|
|
|
<input /> |
|
|
|
</Form.Item> |
|
|
|
</Form>, |
|
|
|
); |
|
|
|
|
|
|
|
expect(wrapper.exists('.ant-form-item-with-help')).toBeTruthy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('warning when use v3 function', () => { |
|
|
|