diff --git a/components/input-number/__tests__/suffix.test.tsx b/components/input-number/__tests__/suffix.test.tsx index 3e07184d59..9e25deec46 100644 --- a/components/input-number/__tests__/suffix.test.tsx +++ b/components/input-number/__tests__/suffix.test.tsx @@ -17,20 +17,16 @@ describe('suffix', () => { expect(mockFocus).toHaveBeenCalled(); }); - it('should has classname when without controls', () => { - const { container } = render(antd} controls={false} />); - + it.each([ + ['controls=false', { controls: false }], + // https://github.com/ant-design/ant-design/issues/53181 + ['disabled', { disabled: true }], + // https://github.com/ant-design/ant-design/discussions/54583 + ['readOnly', { readOnly: true }], + ])('should not show the control buttons when inputNumber is %s', (_, props) => { + const { container } = render(); expect( container.querySelector('.ant-input-number-affix-wrapper-without-controls'), ).toBeTruthy(); }); - - it('should not show the control buttons when inputNumber is disabled', () => { - // Since the hover effect cannot be tested in the jsdom environment - // Just to make sure whether there is a corresponding classname - const { container } = render(); - expect(container.querySelector('.ant-input-number-affix-wrapper')).toHaveClass( - 'ant-input-number-affix-wrapper-without-controls', - ); - }); }); diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index 67843ed3c8..b69c8b4daf 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -170,7 +170,8 @@ const InputNumber = React.forwardRef((props, [`${prefixCls}-affix-wrapper-sm`]: mergedSize === 'small', [`${prefixCls}-affix-wrapper-lg`]: mergedSize === 'large', [`${prefixCls}-affix-wrapper-rtl`]: direction === 'rtl', - [`${prefixCls}-affix-wrapper-without-controls`]: controls === false || mergedDisabled, + [`${prefixCls}-affix-wrapper-without-controls`]: + controls === false || mergedDisabled || readOnly, }, hashId, ),