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

View File

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

View File

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