path and password resets successfully on parent change (#635)

This commit is contained in:
Thibaut Sardan
2021-01-28 13:18:30 +01:00
committed by GitHub
parent 9046da1ee5
commit 9afc0cc512
2 changed files with 10 additions and 1 deletions
@@ -5,7 +5,7 @@ import type { ThemeProps } from '../../types';
import { faLock, faLockOpen } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import styled from 'styled-components';
import { Button, InputWithLabel } from '../../components';
@@ -26,6 +26,10 @@ function DerivationPath ({ className, defaultPath, isError, onChange, withSoftPa
const [path, setPath] = useState<string>(defaultPath);
const [isDisabled, setIsDisabled] = useState(true);
useEffect(() => {
setPath(defaultPath);
}, [defaultPath]);
const _onExpand = useCallback(() => setIsDisabled(!isDisabled), [isDisabled]);
const _onChange = useCallback((newPath: string): void => {
@@ -40,6 +40,11 @@ export default function SelectParent ({ className, isLocked, onDerivationConfirm
return parent?.type === 'sr25519';
}, [accounts, parentAddress]);
// reset the password field if the parent address changes
useEffect(() => {
setParentPassword('');
}, [parentAddress]);
useEffect(() => {
// forbid the use of password since Keyring ignores it
if (suriPath?.includes('///')) {