Adjust logic for NoneField

This commit is contained in:
Connor Bryan 2018-06-29 17:32:02 -05:00
parent 92924524dd
commit 8e8b5e5e30
3 changed files with 11 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import './NonceField.scss';
interface OwnProps {
alwaysDisplay: boolean;
showInvalidBeforeBlur?: boolean;
}
interface StateProps {
@ -27,7 +28,13 @@ type Props = OwnProps & DispatchProps & StateProps;
class NonceField extends React.Component<Props> {
public render() {
const { alwaysDisplay, requestNonce, noncePending, isOffline } = this.props;
const {
alwaysDisplay,
showInvalidBeforeBlur,
requestNonce,
noncePending,
isOffline
} = this.props;
return (
<NonceFieldFactory
withProps={({ nonce: { raw, value }, onChange, readOnly, shouldDisplay }) => {
@ -51,6 +58,7 @@ class NonceField extends React.Component<Props> {
onChange={onChange}
disabled={noncePending}
showInvalidWithoutValue={true}
showInvalidBeforeBlur={showInvalidBeforeBlur}
/>
{noncePending ? (
<div className="Nonce-spinner">

View File

@ -106,7 +106,7 @@ class AdvancedGas extends React.Component<Props, State> {
)}
{nonceField && (
<div className="AdvancedGas-nonce">
<NonceField alwaysDisplay={true} />
<NonceField alwaysDisplay={true} showInvalidBeforeBlur={true} />
</div>
)}
</div>

View File

@ -49,7 +49,7 @@ class Input extends React.Component<Props, State> {
} else if (!hasBlurred && !showInvalidBeforeBlur) {
validClass = '';
}
if (!isStateless && !hasValue && showInvalidWithoutValue) {
if ((!isStateless || showInvalidBeforeBlur) && !hasValue && showInvalidWithoutValue) {
validClass = 'invalid';
}