Skip to content

Commit

Permalink
bug: Reset enteredEns on Address input when changing the value (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
carletex authored Sep 6, 2024
1 parent ae698c4 commit 8dcdf01
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/nextjs/components/scaffold-eth/Input/AddressInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { blo } from "blo";
import { useDebounceValue } from "usehooks-ts";
import { Address, isAddress } from "viem";
Expand Down Expand Up @@ -66,13 +66,9 @@ export const AddressInput = ({ value, name, placeholder, onChange, disabled }: C
onChange(ensAddress);
}, [ensAddress, onChange, debouncedValue]);

const handleChange = useCallback(
(newValue: Address) => {
setEnteredEnsName(undefined);
onChange(newValue);
},
[onChange],
);
useEffect(() => {
setEnteredEnsName(undefined);
}, [value]);

const reFocus =
isEnsAddressError ||
Expand All @@ -88,7 +84,7 @@ export const AddressInput = ({ value, name, placeholder, onChange, disabled }: C
placeholder={placeholder}
error={ensAddress === null}
value={value as Address}
onChange={handleChange}
onChange={onChange}
disabled={isEnsAddressLoading || isEnsNameLoading || disabled}
reFocus={reFocus}
prefix={
Expand Down

0 comments on commit 8dcdf01

Please sign in to comment.