path and password resets successfully on parent change (#635)
This commit is contained in:
@@ -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('///')) {
|
||||
|
||||
Reference in New Issue
Block a user