Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 6e7c627

Browse files
danielkaxisTigge
authored andcommitted
Revert "feat(input): show decimals if step is defined"
This reverts commit 846092f.
1 parent 1f95b34 commit 6e7c627

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

packages/core/src/Input/Input.tsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
RefObject,
1010
KeyboardEventHandler,
1111
MouseEventHandler,
12-
useMemo,
1312
} from 'react'
1413
import styled, { css, useTheme } from 'styled-components'
1514

@@ -22,7 +21,7 @@ import { VisibilityIcon, NotVisibilityIcon, ErrorIcon } from './icons'
2221

2322
type BaseElement = HTMLInputElement
2423
type BaseProps = InputHTMLAttributes<BaseElement>
25-
export type NumberInputType = number | string | ''
24+
export type NumberInputType = number | ''
2625
export type InputChangeHandler = ChangeEventHandler<BaseElement>
2726
export type InputValueChangeHandler<T> = (value: T) => void
2827
export type TextInputWidth = 'small' | 'medium' | 'large' | 'full'
@@ -469,36 +468,9 @@ export const TextInput: FC<TextInputProps> = props => (
469468
)
470469

471470
export interface NumberInputProps extends BaseInputProps<NumberInputType> {}
472-
export const NumberInput: FC<NumberInputProps> = ({
473-
value,
474-
step,
475-
...props
476-
}) => {
477-
const decimalValue = useMemo(() => {
478-
if (step === undefined) {
479-
return 0
480-
}
481-
const [_, decimals] = step.toString().split('.') as [
482-
string,
483-
string | undefined
484-
]
485-
486-
return decimals?.length ?? 0
487-
}, [step])
488-
489-
return (
490-
<Input
491-
value={
492-
step !== undefined && value !== ''
493-
? parseFloat(value.toString()).toFixed(decimalValue)
494-
: value
495-
}
496-
step={step}
497-
{...props}
498-
type="number"
499-
/>
500-
)
501-
}
471+
export const NumberInput: FC<NumberInputProps> = props => (
472+
<Input {...props} type="number" />
473+
)
502474

503475
export interface TextInputCredentialsProps extends BaseInputProps<string> {
504476
readonly type: TextInputCredentialsType

0 commit comments

Comments
 (0)