diff --git a/components/SourceBrowser/index.tsx b/components/SourceBrowser/index.tsx index 289fd2ac9..78b419862 100644 --- a/components/SourceBrowser/index.tsx +++ b/components/SourceBrowser/index.tsx @@ -152,6 +152,19 @@ export const SourceBrowser = ({ } }, [chain, address]); + const onAbiChange = useCallback(async () => { + if (source.startsWith("http") || source.startsWith("/")) { + onUrlChange(source); + } else { + try { + const jsonContent = JSON.parse(source); + onJsonChange(jsonContent); + } catch (err) { + onError(err); + } + } + }, [source]); + return ( <> { if (event.key === "Enter") { - if (source.startsWith("http")) { - onUrlChange(source); - } else { - try { - const jsonContent = JSON.parse(source); - onJsonChange(jsonContent); - } catch (err) { - onError(err); - } - } + onAbiChange(); } }} + onBlur={onAbiChange} fullWidth id="file" label="ABI"