diff --git a/packages/ui/src/components/EasySetup/SetIdentity.tsx b/packages/ui/src/components/EasySetup/SetIdentity.tsx index a44932c9..6ee81739 100644 --- a/packages/ui/src/components/EasySetup/SetIdentity.tsx +++ b/packages/ui/src/components/EasySetup/SetIdentity.tsx @@ -102,6 +102,7 @@ const SetIdentity = ({ className, onSetExtrinsic, from, onSetErrorMessage }: Pro const { api, chainInfo } = useApi() const [identityFields, setIdentityFields] = useState() const chainIdentity = useIdentity(from) + const [hasChangedAtLeastAField, setHasChangedAtLeastAField] = useState(false) const fieldtooLongError = useMemo(() => { const res: (keyof IdentityFields)[] = [] identityFields && @@ -120,13 +121,13 @@ const SetIdentity = ({ className, onSetExtrinsic, from, onSetErrorMessage }: Pro return } - if (!identityFields?.display) { + if (!identityFields?.display && hasChangedAtLeastAField) { onSetErrorMessage('Display name is required') return } onSetErrorMessage('') - }, [fieldtooLongError, identityFields?.display, onSetErrorMessage]) + }, [fieldtooLongError, hasChangedAtLeastAField, identityFields, onSetErrorMessage]) useEffect(() => { if (chainIdentity) { @@ -172,6 +173,7 @@ const SetIdentity = ({ className, onSetExtrinsic, from, onSetErrorMessage }: Pro }, [api, chainInfo, fieldtooLongError, identityFields, onSetErrorMessage, onSetExtrinsic]) const onChangeField = useCallback((field: keyof IdentityFields, value: string) => { + setHasChangedAtLeastAField(true) setIdentityFields((prev) => (prev ? { ...prev, [field]: value } : undefined)) }, []) @@ -187,7 +189,7 @@ const SetIdentity = ({ className, onSetExtrinsic, from, onSetErrorMessage }: Pro fieldName as keyof IdentityFields ) const isFieldError = fieldtooLongError.includes(fieldName as keyof IdentityFields) - const isDiplayAndEmpty = fieldName === 'display' && !value + const isDiplayNameError = fieldName === 'display' && !value && hasChangedAtLeastAField return ( ) diff --git a/packages/ui/src/contexts/NetworkContext.tsx b/packages/ui/src/contexts/NetworkContext.tsx index 9893d2f6..927f9c35 100644 --- a/packages/ui/src/contexts/NetworkContext.tsx +++ b/packages/ui/src/contexts/NetworkContext.tsx @@ -8,13 +8,13 @@ type NetworkContextProps = { children: React.ReactNode | React.ReactNode[] } -export interface IToastContext { +export interface INetworkContext { selectNetwork: (network: string) => void selectedNetworkInfo?: NetworkInfo selectedNetwork?: SupportedNetworks } -const NetworkContext = React.createContext(undefined) +const NetworkContext = React.createContext(undefined) const isSupportedNetwork = (network: string): network is SupportedNetworks => !!networkList[network as SupportedNetworks]