diff --git a/components/ui/phone-input.tsx b/components/ui/phone-input.tsx index 2406554..db50b06 100644 --- a/components/ui/phone-input.tsx +++ b/components/ui/phone-input.tsx @@ -28,7 +28,7 @@ type PhoneInputProps = Omit, "onChan const PhoneInput: React.ForwardRefExoticComponent = React.forwardRef< React.ElementRef, PhoneInputProps ->(({ className, ...props }, ref) => ( +>(({ className, onChange, ...props }, ref) => ( = React.forwa flagComponent={FlagComponent} countrySelectComponent={CountrySelect} inputComponent={InputComponent} + /** + * Handles the onChange event. + * + * react-phone-number-input might trigger the onChange event as undefined + * when a valid phone number is not entered. To prevent this, + * the value is coerced to an empty string. + * + * @param {E164Number | undefined} value - The entered value + */ + onChange={(value) => onChange(value || "")} {...props} /> ));