reset_multifield

pull/2063/head^2
yann300 3 years ago
parent 7c163ea850
commit dfe738d76b
  1. 10
      apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
  2. 6
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx

@ -202,10 +202,10 @@ module.exports = {
.addFile('Storage.sol', sources[6]['Storage.sol']) .addFile('Storage.sol', sources[6]['Storage.sol'])
.addFile('Owner.sol', sources[6]['Owner.sol']) .addFile('Owner.sol', sources[6]['Owner.sol'])
.clickLaunchIcon('udapp') .clickLaunchIcon('udapp')
.createContract('42') .createContract('42, 24')
.openFile('Storage.sol') .openFile('Storage.sol')
.clickLaunchIcon('udapp') .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) .clickInstance(1)
.clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' }) .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' })
.testFunction('last', // we check if the contract is actually reachable. .testFunction('last', // we check if the contract is actually reachable.
@ -375,7 +375,7 @@ contract C {
/** /**
* @dev Set contract deployer as owner * @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 owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
emit OwnerSet(address(0), owner); emit OwnerSet(address(0), owner);
} }
@ -412,6 +412,10 @@ contract C {
uint256 number; uint256 number;
constructor(uint p) {
}
/** /**
* @dev Store value in variable * @dev Store value in variable
* @param num value to store * @param num value to store

@ -16,6 +16,7 @@ export function ContractGUI (props: ContractGUIProps) {
dataId: string dataId: string
}>({ title: '', content: '', classList: '', dataId: '' }) }>({ title: '', content: '', classList: '', dataId: '' })
const multiFields = useRef<Array<HTMLInputElement | null>>([]) const multiFields = useRef<Array<HTMLInputElement | null>>([])
const basicInputRef = useRef<HTMLInputElement>()
useEffect(() => { useEffect(() => {
if (props.title) { if (props.title) {
@ -26,6 +27,10 @@ export function ContractGUI (props: ContractGUIProps) {
setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)') setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)')
} }
setBasicInput('') 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]) }, [props.title, props.funcABI])
useEffect(() => { useEffect(() => {
@ -166,6 +171,7 @@ export function ContractGUI (props: ContractGUIProps) {
placeholder={props.inputs} placeholder={props.inputs}
title={props.funcABI.type === 'fallback' || props.funcABI.type === 'receive' ? `'(${props.funcABI.type}')` : props.inputs} title={props.funcABI.type === 'fallback' || props.funcABI.type === 'receive' ? `'(${props.funcABI.type}')` : props.inputs}
onChange={handleBasicInput} onChange={handleBasicInput}
ref={basicInputRef}
style={{ visibility: !((props.funcABI.inputs && props.funcABI.inputs.length > 0) || (props.funcABI.type === 'fallback') || (props.funcABI.type === 'receive')) ? 'hidden' : 'visible' }} /> style={{ visibility: !((props.funcABI.inputs && props.funcABI.inputs.length > 0) || (props.funcABI.type === 'fallback') || (props.funcABI.type === 'receive')) ? 'hidden' : 'visible' }} />
<i <i
className="fas fa-angle-down udapp_methCaret" className="fas fa-angle-down udapp_methCaret"

Loading…
Cancel
Save