Closed pikselinweb closed 4 months ago
I solved issue by use Controller.
<Controller
control={control}
name="code"
render={({ field: { onChange, onBlur, value } }) => (
<Autocomplete
selectedKey={value}
label={t("common.code")}
variant="bordered"
placeholder={t("common.code")}
labelPlacement="outside"
className="w-full sm:w-32"
defaultItems={countriesWithDialCode}
radius="sm"
classNames={{ base: "font-bold" }}
isInvalid={has(errors, "code")}
errorMessage={errors.code?.message}
{...register("code")}
onSelectionChange={value =>
onChange({ target: { value } })
}
onBlur={onBlur}
>
{item => (
<AutocompleteItem
key={item.code}
value={item.code}
>
{item.dial_code}
</AutocompleteItem>
)}
</Autocomplete>
)}
/>
registering all props may cause problem with react hook form.
NextUI Version
@nextui-org/react
Describe the bug
I am using Next ui with react hook form. When i select item set correctly. But when i type something in other component it value switch to display value.
here is the problem output:
When i input phone number it switch to display value in this example.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Expected behavior
County code must be as auto complete item value.
Screenshots or Videos
No response
Operating System Version
MacOs
Browser
Chrome