From f5a9622fd37c058765dbffde17475e76288e6956 Mon Sep 17 00:00:00 2001 From: Connor Bryan Date: Mon, 25 Jun 2018 18:35:04 -0500 Subject: [PATCH] Undo changes to Input and pass down showInvalidWithoutValue --- common/components/AmountField.tsx | 6 ++++-- common/components/ui/Input.tsx | 15 +++++++-------- .../SendTransaction/components/Fields/Fields.tsx | 6 +++++- .../SendTransaction/components/RequestPayment.tsx | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/common/components/AmountField.tsx b/common/components/AmountField.tsx index 1418ff5d..97606e37 100644 --- a/common/components/AmountField.tsx +++ b/common/components/AmountField.tsx @@ -10,13 +10,15 @@ interface Props { hasSendEverything?: boolean; showAllTokens?: boolean; customValidator?(rawAmount: string): boolean; + showInvalidWithoutValue?: boolean; } export const AmountField: React.SFC = ({ hasUnitDropdown, hasSendEverything, showAllTokens, - customValidator + customValidator, + showInvalidWithoutValue }) => ( ( @@ -30,7 +32,7 @@ export const AmountField: React.SFC = ({ value={raw} readOnly={!!readOnly} onChange={onChange} - showInvalidWithoutValue={true} + showInvalidWithoutValue={showInvalidWithoutValue} /> {hasSendEverything && } {hasUnitDropdown && } diff --git a/common/components/ui/Input.tsx b/common/components/ui/Input.tsx index d1578100..c67d8c96 100644 --- a/common/components/ui/Input.tsx +++ b/common/components/ui/Input.tsx @@ -40,17 +40,16 @@ class Input extends React.Component { const hasValue = !!this.props.value && this.props.value.toString().length > 0; // Currently we don't ever highlight valid, so go empty string instead - const validDueToValue = !hasValue && !showInvalidWithoutValue; - const validDueToBlur = !hasBlurred && !showInvalidBeforeBlur; let validClass = isValid ? '' : 'invalid'; - - // Override validity based on initial conditions. - if (isStateless || validDueToValue || validDueToBlur) { + if (isStateless) { validClass = ''; } - - // Show an error with no value only after blurring. - if (!isStateless && !validDueToBlur && !hasValue && showInvalidWithoutValue) { + if (!hasValue && !showInvalidWithoutValue) { + validClass = ''; + } else if (!hasBlurred && !showInvalidBeforeBlur) { + validClass = ''; + } + if (!isStateless && !hasValue && showInvalidWithoutValue) { validClass = 'invalid'; } diff --git a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx index 7cf85fa5..e55f26fc 100644 --- a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx +++ b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx @@ -54,7 +54,11 @@ class FieldsClass extends Component {
- +
{schedulingAvailable && (
diff --git a/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx b/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx index 3f7cfbbc..e47b53d9 100644 --- a/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx +++ b/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx @@ -101,7 +101,7 @@ class RequestPayment extends React.Component {