diff --git a/src/routes/open/components/SafeOwnersConfirmationsForm/ScanQRModal/index.jsx b/src/routes/open/components/SafeOwnersConfirmationsForm/ScanQRModal/index.jsx index 6455aa2c..80405529 100644 --- a/src/routes/open/components/SafeOwnersConfirmationsForm/ScanQRModal/index.jsx +++ b/src/routes/open/components/SafeOwnersConfirmationsForm/ScanQRModal/index.jsx @@ -45,6 +45,9 @@ const ScanQRModal = ({ }, []) useEffect(() => { + // this fires only when the hasWebcam changes to false (null > false (user doesn't have webcam) + // , true > false (user switched from webcam to file upload)) + // Doesn't fire on re-render if (hasWebcam === false) { openImageDialog() } diff --git a/src/routes/open/components/SafeOwnersConfirmationsForm/index.jsx b/src/routes/open/components/SafeOwnersConfirmationsForm/index.jsx index 60b9de1d..dab13156 100644 --- a/src/routes/open/components/SafeOwnersConfirmationsForm/index.jsx +++ b/src/routes/open/components/SafeOwnersConfirmationsForm/index.jsx @@ -58,8 +58,8 @@ export const calculateValuesAfterRemoving = (index: number, notRemovedOwners: nu initialValues[FIELD_CONFIRMATIONS] = numOwnersAfterRemoving.toString() } - delete initialValues[getOwnerNameBy(numOwnersAfterRemoving)] - delete initialValues[getOwnerAddressBy(numOwnersAfterRemoving)] + delete initialValues[getOwnerNameBy(index)] + delete initialValues[getOwnerAddressBy(index)] return initialValues } @@ -87,7 +87,14 @@ const SafeOwners = (props: Props) => { form.reset() } else { const initialValues = calculateValuesAfterRemoving(index, numOwners, values) - updateInitialProps(initialValues) + + if (Object.keys(initialValues).length === 4) { + // this means that the form is back to its inital state + // and if they're equal it won't update the form + form.reset() + } else { + updateInitialProps(initialValues) + } } setNumOwners(numOwners - 1) diff --git a/src/routes/open/components/fields.js b/src/routes/open/components/fields.js index 897eb4e4..fa280c90 100644 --- a/src/routes/open/components/fields.js +++ b/src/routes/open/components/fields.js @@ -9,7 +9,7 @@ export const getOwnerAddressBy = (index: number) => `owner${index}Address` export const getNumOwnersFrom = (values: Object) => { const accounts = Object.keys(values) .sort() - .filter(key => /^owner\d+Name$/.test(key)) + .filter(key => /^owner\d+Address$/.test(key) && !!values[key]) return accounts.length }