From 1f7bd9e259dc537d5432c739a456ca0d74d92554 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 28 Sep 2022 21:34:02 +0200 Subject: [PATCH] setSelectedContract when file changes --- .../run-tab/src/lib/components/contractDropdownUI.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index 298db6a324..0f9f1d9cab 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -99,6 +99,15 @@ export function ContractDropdownUI (props: ContractDropdownProps) { initSelectedContract() }, [contractList]) + useEffect(() => { + // if the file change the ui is already feed with another bunch of contracts. + // we also need to update the state + const contracts = contractList[currentFile] + if (contracts && contracts.length > 0) { + props.setSelectedContract(contracts[0].alias) + } + }, [currentFile]) + const initSelectedContract = () => { const contracts = contractList[currentFile]