Commit 7125562c authored by aballerr's avatar aballerr Committed by GitHub

fix: fixing issue with decimal in price range (#4784)

* fixing issue with decimal in price range
parent 1361f996
......@@ -2,7 +2,6 @@ import { Row } from 'nft/components/Flex'
import { NumericInput } from 'nft/components/layout/Input'
import { useIsMobile } from 'nft/hooks'
import { useCollectionFilters } from 'nft/hooks/useCollectionFilters'
import { isNumber } from 'nft/utils/numbers'
import { scrollToTop } from 'nft/utils/scrollToTop'
import { useEffect, useState } from 'react'
import { FocusEventHandler, FormEvent } from 'react'
......@@ -50,7 +49,7 @@ export const PriceRange = () => {
defaultValue={minPrice}
onChange={(v: FormEvent<HTMLInputElement>) => {
scrollToTop()
setMinPrice(isNumber(v.currentTarget.value) ? parseFloat(v.currentTarget.value) : '')
setMinPrice(v.currentTarget.value)
}}
onFocus={handleFocus}
value={minPrice}
......@@ -74,7 +73,7 @@ export const PriceRange = () => {
value={maxPrice}
onChange={(v: FormEvent<HTMLInputElement>) => {
scrollToTop()
setMaxPrice(isNumber(v.currentTarget.value) ? parseFloat(v.currentTarget.value) : '')
setMaxPrice(v.currentTarget.value)
}}
onFocus={handleFocus}
onBlur={handleBlur}
......
......@@ -29,6 +29,10 @@ export const NumericInput = forwardRef<HTMLInputElement, BoxProps>((props, ref)
autoComplete="off"
type="text"
onInput={(v: FormEvent<HTMLInputElement>) => {
if (v.currentTarget.value === '.') {
v.currentTarget.value = '0.'
}
v.currentTarget.value =
!!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
? v.currentTarget.value
......
......@@ -25,8 +25,8 @@ export type Trait = {
interface State {
traits: Trait[]
markets: string[]
minPrice: number | ''
maxPrice: number | ''
minPrice: string
maxPrice: string
minRarity: number | ''
maxRarity: number | ''
marketCount: Record<string, number>
......@@ -43,8 +43,8 @@ type Actions = {
addTrait: (trait: Trait) => void
removeTrait: (trait: Trait) => void
reset: () => void
setMinPrice: (price: number | '') => void
setMaxPrice: (price: number | '') => void
setMinPrice: (price: string) => void
setMaxPrice: (price: string) => void
setMinRarity: (range: number | '') => void
setMaxRarity: (range: number | '') => void
setBuyNow: (bool: boolean) => void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment