Skip to content

Commit

Permalink
fix(ui): fix zero in number / float input
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Dec 12, 2023
1 parent 4f7da41 commit 1d64f81
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/Forms/Inputs/FloatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const FloatInput = memo(forwardRef<HTMLInputElement, FloatInputProps>(({
.replaceAll(',', '.')
.replace(/[^\d.-]/g, '')
.replace(/^(-?\d+\.\d+|\d+).*/, '$1')
.replace(/^(-?)0+/, (match, p1) => p1 === '-' ? '-0' : '')
.replace(/^(-?)0+/, (match, p1) => p1 === '-' ? '-0' : '0')
: ''

if (number.current !== value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Forms/Inputs/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const NumberInput = memo(forwardRef<HTMLInputElement, NumberInputProps>((
? (value)
.trim()
.replace(/[^0-9-]|(?<!^)-/g, '')
.replace(/^(-?)0+/, (match, p1) => p1 === '-' ? '-0' : '')
.replace(/^(-?)0+/, (match, p1) => p1 === '-' ? '-0' : '0')
: null

const int = value ? parseInt(value, 10) : null
Expand Down

0 comments on commit 1d64f81

Please sign in to comment.