diff --git a/packages/svelte/src/lib/components/scaffold-eth/inputs/AddressInput.svelte b/packages/svelte/src/lib/components/scaffold-eth/inputs/AddressInput.svelte index 9488707..073a203 100644 --- a/packages/svelte/src/lib/components/scaffold-eth/inputs/AddressInput.svelte +++ b/packages/svelte/src/lib/components/scaffold-eth/inputs/AddressInput.svelte @@ -6,8 +6,16 @@ import { blo } from "blo"; import { normalize } from "viem/ens"; - // eslint-disable-next-line no-undef - let { value = $bindable(), name, placeholder, onchange, disabled }: CommonInputProps
= $props(); + let { + // eslint-disable-next-line no-undef + value = $bindable(), + // eslint-disable-next-line no-undef + address = $bindable(), + name, + placeholder, + onchange, + disabled, + }: CommonInputProps & { address?: string | undefined; ens?: string | undefined } = $props(); let rawDebouncedValue: string | undefined = $state(undefined); let debouncedTimeout: number | undefined; @@ -24,6 +32,15 @@ }, 500); }); + $effect(() => { + if (value && isAddress(value)) address = value; + else address = undefined; + }); + + $effect(() => { + if (address) value = address; + }); + // If the user enters an address, don't delay const debouncedValue = $derived(isAddress(value) ? value : rawDebouncedValue); const isDebouncedValueLive = $derived(debouncedValue === value);