Skip to content

Commit 4b75c6e

Browse files
authored
chore: fix types for number input (#10264)
1 parent 4858010 commit 4b75c6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-core/src/components/NumberInput/NumberInput.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ const defaultKeyDownHandler = (args: DefaultKeyDownHandlerArgs) => (event: React
6767
}
6868
};
6969

70+
const DEFAULT_VALUE = 0;
71+
7072
export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
71-
value = 0,
73+
value = DEFAULT_VALUE,
7274
className,
7375
widthChars,
7476
isDisabled = false,
@@ -121,7 +123,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
121123
<Button
122124
variant="control"
123125
aria-label={minusBtnAriaLabel}
124-
isDisabled={isDisabled || value <= min}
126+
isDisabled={isDisabled || (typeof value === 'number' ? value : DEFAULT_VALUE) <= min}
125127
onClick={(evt) => onMinus(evt, inputName)}
126128
{...minusBtnProps}
127129
>
@@ -149,7 +151,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
149151
<Button
150152
variant="control"
151153
aria-label={plusBtnAriaLabel}
152-
isDisabled={isDisabled || value >= max}
154+
isDisabled={isDisabled || (typeof value === 'number' ? value : DEFAULT_VALUE) >= max}
153155
onClick={(evt) => onPlus(evt, inputName)}
154156
{...plusBtnProps}
155157
>

0 commit comments

Comments
 (0)