Skip to content

Commit 0e71f37

Browse files
committed
fix: improve inc/dec controls logic
1 parent c1cded6 commit 0e71f37

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/InputNumber.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { HolderRef } from '@rc-component/input/lib/BaseInput';
2121
import { BaseInputProps } from '@rc-component/input/lib/interface';
2222
import { InputFocusOptions, triggerFocus } from '@rc-component/input/lib/utils/commonUtils';
2323
import useFrame from './hooks/useFrame';
24+
import useMobile from '@rc-component/util/lib/hooks/useMobile';
2425

2526
export type { ValueType };
2627

@@ -133,7 +134,7 @@ const InternalInputNumber = React.forwardRef(
133134
downHandler,
134135
keyboard,
135136
changeOnWheel = false,
136-
controls = true,
137+
controls,
137138

138139
stringMode,
139140

@@ -176,6 +177,9 @@ const InternalInputNumber = React.forwardRef(
176177
}
177178
}
178179

180+
const isMobile = useMobile();
181+
const mergedControls = controls ?? !isMobile;
182+
179183
// ====================== Parser & Formatter ======================
180184
/**
181185
* `precision` is used for formatter & onChange.
@@ -607,7 +611,7 @@ const InternalInputNumber = React.forwardRef(
607611
onCompositionEnd={onCompositionEnd}
608612
onBeforeInput={onBeforeInput}
609613
>
610-
{controls && (
614+
{mergedControls && (
611615
<StepHandler
612616
prefixCls={prefixCls}
613617
upNode={upHandler}

src/StepHandler.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable react/no-unknown-property */
22
import * as React from 'react';
33
import cls from 'classnames';
4-
import useMobile from '@rc-component/util/lib/hooks/useMobile';
54
import raf from '@rc-component/util/lib/raf';
65
import SemanticContext from './SemanticContext';
76

@@ -71,11 +70,6 @@ export default function StepHandler({
7170
);
7271

7372
// ======================= Render =======================
74-
const isMobile = useMobile();
75-
if (isMobile) {
76-
return null;
77-
}
78-
7973
const handlerClassName = `${prefixCls}-handler`;
8074

8175
const upClassName = cls(handlerClassName, `${handlerClassName}-up`, {

0 commit comments

Comments
 (0)