From 31de06ec0c177b1d01a67f20707d4bec6a2434a2 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 28 Feb 2022 09:41:06 +0100 Subject: [PATCH] Fix deploy button toggle when switching between files. --- .../src/lib/components/contractDropdownUI.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 d367038e8a..2bed9523aa 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -95,10 +95,12 @@ export function ContractDropdownUI (props: ContractDropdownProps) { }, [contractList]) const initSelectedContract = () => { - if (contractList[currentFile] && contractList[currentFile].length > 0) { - const contract = contractList[currentFile].find(contract => contract.alias === selectedContract) + const contracts = contractList[currentFile] + + if (contracts && contracts.length > 0) { + const contract = contracts.find(contract => contract.alias === selectedContract) - if (!selectedContract || !contract) setSelectedContract(contractList[currentFile][0].alias) + if (!selectedContract || !contract) setSelectedContract(contracts[0].alias) } } @@ -202,16 +204,16 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
- { (contractList[currentFile] && contractList[currentFile].length <= 0) && } + { (contractList[currentFile] || []).length <= 0 && } { abiLabel.content }
- { contractList[currentFile] && contractList[currentFile].length <= 0 ? 'No compiled contracts' + { ((contractList[currentFile] && contractList[currentFile].filter(contract => contract)) || []).length <= 0 ? 'No compiled contracts' : loadedContractData ?