mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-15 13:38:29 +02:00
fix(InputNumber): fix suffix shift on hover in readonly state (#54585)
This commit is contained in:
parent
f5f8967148
commit
5f75711a80
2 changed files with 10 additions and 13 deletions
|
@ -17,20 +17,16 @@ describe('suffix', () => {
|
||||||
expect(mockFocus).toHaveBeenCalled();
|
expect(mockFocus).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should has classname when without controls', () => {
|
it.each([
|
||||||
const { container } = render(<InputNumber suffix={<i>antd</i>} controls={false} />);
|
['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(<InputNumber suffix="RMB" style={{ width: '100%' }} {...props} />);
|
||||||
expect(
|
expect(
|
||||||
container.querySelector('.ant-input-number-affix-wrapper-without-controls'),
|
container.querySelector('.ant-input-number-affix-wrapper-without-controls'),
|
||||||
).toBeTruthy();
|
).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(<InputNumber suffix="RMB" style={{ width: '100%' }} disabled />);
|
|
||||||
expect(container.querySelector('.ant-input-number-affix-wrapper')).toHaveClass(
|
|
||||||
'ant-input-number-affix-wrapper-without-controls',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -170,7 +170,8 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
||||||
[`${prefixCls}-affix-wrapper-sm`]: mergedSize === 'small',
|
[`${prefixCls}-affix-wrapper-sm`]: mergedSize === 'small',
|
||||||
[`${prefixCls}-affix-wrapper-lg`]: mergedSize === 'large',
|
[`${prefixCls}-affix-wrapper-lg`]: mergedSize === 'large',
|
||||||
[`${prefixCls}-affix-wrapper-rtl`]: direction === 'rtl',
|
[`${prefixCls}-affix-wrapper-rtl`]: direction === 'rtl',
|
||||||
[`${prefixCls}-affix-wrapper-without-controls`]: controls === false || mergedDisabled,
|
[`${prefixCls}-affix-wrapper-without-controls`]:
|
||||||
|
controls === false || mergedDisabled || readOnly,
|
||||||
},
|
},
|
||||||
hashId,
|
hashId,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue