Fix select not resetting on new views
This commit is contained in:
parent
dc86e712cb
commit
c51c16de09
1 changed files with 7 additions and 3 deletions
|
|
@ -13,7 +13,6 @@ interface Props
|
|||
HTMLSelectElement
|
||||
> {
|
||||
open: boolean
|
||||
placeholder?: string
|
||||
trigger?: React.ReactNode
|
||||
children?: React.ReactNode
|
||||
onClick?: () => void
|
||||
|
|
@ -25,7 +24,8 @@ const Select = (props: Props) => {
|
|||
const [value, setValue] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (props.value) setValue(`${props.value}`)
|
||||
if (props.value && props.value !== '') setValue(`${props.value}`)
|
||||
else setValue('')
|
||||
}, [props.value])
|
||||
|
||||
function onValueChange(newValue: string) {
|
||||
|
|
@ -33,8 +33,12 @@ const Select = (props: Props) => {
|
|||
if (props.onValueChange) props.onValueChange(newValue)
|
||||
}
|
||||
|
||||
console.log(value)
|
||||
return (
|
||||
<RadixSelect.Root value={value} onValueChange={onValueChange}>
|
||||
<RadixSelect.Root
|
||||
value={value !== '' ? value : undefined}
|
||||
onValueChange={onValueChange}
|
||||
>
|
||||
<RadixSelect.Trigger
|
||||
className={classNames('SelectTrigger', props.triggerClass)}
|
||||
placeholder={props.placeholder}
|
||||
|
|
|
|||
Loading…
Reference in a new issue