From bda8cb0a7644df9a3647edd8766a7cfa9eb7f73d Mon Sep 17 00:00:00 2001 From: ice <49827327+coding-ice@users.noreply.github.com> Date: Fri, 16 Aug 2024 20:07:26 +0800 Subject: [PATCH] fix(input-number): without controls suffix style (#50450) Co-authored-by: afc163 --- components/input-number/__tests__/suffix.test.tsx | 8 ++++++++ components/input-number/index.tsx | 1 + components/input-number/style/index.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/input-number/__tests__/suffix.test.tsx b/components/input-number/__tests__/suffix.test.tsx index ac4d79af8e..98b18ba922 100644 --- a/components/input-number/__tests__/suffix.test.tsx +++ b/components/input-number/__tests__/suffix.test.tsx @@ -16,4 +16,12 @@ describe('suffix', () => { fireEvent.click(container.querySelector('i')!); expect(mockFocus).toHaveBeenCalled(); }); + + it('should has classname when without controls', () => { + const { container } = render(antd} controls={false} />); + + expect( + container.querySelector('.ant-input-number-affix-wrapper-without-controls'), + ).toBeTruthy(); + }); }); diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index 5c3cbcc103..9004c66a4f 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -171,6 +171,7 @@ 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, }, hashId, ), diff --git a/components/input-number/style/index.ts b/components/input-number/style/index.ts index 6da2d7617c..14851c8e0a 100644 --- a/components/input-number/style/index.ts +++ b/components/input-number/style/index.ts @@ -469,7 +469,7 @@ const genAffixWrapperStyles: GenerateStyle = (token: InputNumb width: token.handleWidth, opacity: 1, }, - [`&:hover ${componentCls}-suffix`]: { + [`&:not(${componentCls}-affix-wrapper-without-controls):hover ${componentCls}-suffix`]: { marginInlineEnd: token.calc(token.handleWidth).add(paddingInline).equal(), }, },