Skip to content

Commit

Permalink
chore: fix types for number input (#10264)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops authored Apr 19, 2024
1 parent 4858010 commit 4b75c6e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ const defaultKeyDownHandler = (args: DefaultKeyDownHandlerArgs) => (event: React
}
};

const DEFAULT_VALUE = 0;

export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
value = 0,
value = DEFAULT_VALUE,
className,
widthChars,
isDisabled = false,
Expand Down Expand Up @@ -121,7 +123,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
<Button
variant="control"
aria-label={minusBtnAriaLabel}
isDisabled={isDisabled || value <= min}
isDisabled={isDisabled || (typeof value === 'number' ? value : DEFAULT_VALUE) <= min}
onClick={(evt) => onMinus(evt, inputName)}
{...minusBtnProps}
>
Expand Down Expand Up @@ -149,7 +151,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
<Button
variant="control"
aria-label={plusBtnAriaLabel}
isDisabled={isDisabled || value >= max}
isDisabled={isDisabled || (typeof value === 'number' ? value : DEFAULT_VALUE) >= max}
onClick={(evt) => onPlus(evt, inputName)}
{...plusBtnProps}
>
Expand Down

0 comments on commit 4b75c6e

Please sign in to comment.