From dfe738d76b8a203e9b74e3f58bf715f33fee009b Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Feb 2022 10:17:32 +0100 Subject: [PATCH] reset_multifield --- .../src/tests/transactionExecution.test.ts | 10 +++++++--- .../run-tab/src/lib/components/contractGUI.tsx | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index feb70d7d62..da26b27793 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -202,10 +202,10 @@ module.exports = { .addFile('Storage.sol', sources[6]['Storage.sol']) .addFile('Owner.sol', sources[6]['Owner.sol']) .clickLaunchIcon('udapp') - .createContract('42') + .createContract('42, 24') .openFile('Storage.sol') .clickLaunchIcon('udapp') - .createContract('') // this creation will fail if the component hasn't been properly reset. + .createContract('102') // this creation will fail if the component hasn't been properly reset. .clickInstance(1) .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' }) .testFunction('last', // we check if the contract is actually reachable. @@ -375,7 +375,7 @@ contract C { /** * @dev Set contract deployer as owner */ - constructor(uint p) { + constructor(uint p, uint o) { owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor emit OwnerSet(address(0), owner); } @@ -412,6 +412,10 @@ contract C { uint256 number; + constructor(uint p) { + + } + /** * @dev Store value in variable * @param num value to store diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 7fab3aa9d4..74dade661e 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -16,6 +16,7 @@ export function ContractGUI (props: ContractGUIProps) { dataId: string }>({ title: '', content: '', classList: '', dataId: '' }) const multiFields = useRef>([]) + const basicInputRef = useRef() useEffect(() => { if (props.title) { @@ -26,6 +27,10 @@ export function ContractGUI (props: ContractGUIProps) { setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)') } setBasicInput('') + // we have the reset the fields before reseting the previous references. + basicInputRef.current.value = '' + multiFields.current.filter((el) => el !== null && el !== undefined).forEach((el) => el.value = '') + multiFields.current = [] }, [props.title, props.funcABI]) useEffect(() => { @@ -166,6 +171,7 @@ export function ContractGUI (props: ContractGUIProps) { placeholder={props.inputs} title={props.funcABI.type === 'fallback' || props.funcABI.type === 'receive' ? `'(${props.funcABI.type}')` : props.inputs} onChange={handleBasicInput} + ref={basicInputRef} style={{ visibility: !((props.funcABI.inputs && props.funcABI.inputs.length > 0) || (props.funcABI.type === 'fallback') || (props.funcABI.type === 'receive')) ? 'hidden' : 'visible' }} />