diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index fb5dd7fef7..d04a33850f 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -224,7 +224,8 @@ function FormItem(props: FormItemProps): 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 diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.js index 9122060c4b..324033707c 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.js @@ -315,16 +315,30 @@ describe('Form', () => { expect(wrapper.find('.ant-form-item-required')).toHaveLength(1); }); - it('should show related className when customize help', () => { - const wrapper = mount( -
- - - -
, - ); + describe('should show related className when customize help', () => { + it('normal', () => { + const wrapper = mount( +
+ + + +
, + ); - 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( +
+ + + +
, + ); + + expect(wrapper.exists('.ant-form-item-with-help')).toBeTruthy(); + }); }); it('warning when use v3 function', () => {