mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
chore: InputNumber add usage tips (#49648)
This commit is contained in:
parent
abe483d7d0
commit
c4928586af
@ -98,12 +98,18 @@ describe('InputNumber', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('deprecate bordered', () => {
|
||||
it('Deprecation and usage tips', () => {
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const { container } = render(<InputNumber bordered={false} />);
|
||||
expect(errorSpy).toHaveBeenCalledWith(
|
||||
const { container } = render(<InputNumber bordered={false} type="number" changeOnWheel />);
|
||||
expect(errorSpy).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'Warning: [antd: InputNumber] `bordered` is deprecated. Please use `variant` instead.',
|
||||
);
|
||||
expect(errorSpy).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'Warning: [antd: InputNumber] When `type=number` is used together with `changeOnWheel`, changeOnWheel may not work properly. Please delete `type=number` if it is not necessary.',
|
||||
);
|
||||
|
||||
expect(container.querySelector('.ant-input-number-borderless')).toBeTruthy();
|
||||
errorSpy.mockRestore();
|
||||
});
|
||||
|
@ -42,8 +42,13 @@ export interface InputNumberProps<T extends ValueType = ValueType>
|
||||
|
||||
const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props, ref) => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const { deprecated } = devUseWarning('InputNumber');
|
||||
deprecated(!('bordered' in props), 'bordered', 'variant');
|
||||
const typeWarning = devUseWarning('InputNumber');
|
||||
typeWarning.deprecated(!('bordered' in props), 'bordered', 'variant');
|
||||
typeWarning(
|
||||
!(props.type === 'number' && props.changeOnWheel),
|
||||
'usage',
|
||||
'When `type=number` is used together with `changeOnWheel`, changeOnWheel may not work properly. Please delete `type=number` if it is not necessary.',
|
||||
);
|
||||
}
|
||||
|
||||
const { getPrefixCls, direction } = React.useContext(ConfigContext);
|
||||
|
Loading…
Reference in New Issue
Block a user