diff --git a/src/components/form/LookupInput.tsx b/src/components/form/LookupInput.tsx index 9a67a4a..19c70d5 100644 --- a/src/components/form/LookupInput.tsx +++ b/src/components/form/LookupInput.tsx @@ -10,14 +10,17 @@ type LookupInputProps = { onRegistry?: (type: TargetType) => Promise; // When a user hits submit, this is called. onSubmit?: (props: SubmitProps) => Promise; + onChange?: (target: string) => any; }; const LookupInput: FunctionComponent = ({ isLoading, onSubmit, + onChange, }: LookupInputProps) => { - const { register, handleSubmit } = useForm({ + const { register, handleSubmit, getValues } = useForm({ defaultValues: { + target: "", followReferral: false, requestJSContact: false, }, @@ -48,7 +51,12 @@ const LookupInput: FunctionComponent = ({ disabled={isLoading} placeholder="A domain, an IP address, a TLD, an RDAP URL..." type="search" - {...register("target", { required: true })} + {...register("target", { + required: true, + onChange: () => { + if (onChange != undefined) onChange(getValues("target")); + }, + })} />