From be039f9d5ab7d709ed3a051cd007c4092f4eda36 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 14 Nov 2019 11:44:40 +0100 Subject: [PATCH] Fix InputBalance default display (#1880) --- packages/app-council/src/Overview/Vote.tsx | 4 ++-- packages/app-council/src/Overview/VoteValue.tsx | 2 +- packages/react-components/src/InputBalance.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/app-council/src/Overview/Vote.tsx b/packages/app-council/src/Overview/Vote.tsx index 4abe55b82e..7ca1dab789 100644 --- a/packages/app-council/src/Overview/Vote.tsx +++ b/packages/app-council/src/Overview/Vote.tsx @@ -243,8 +243,8 @@ class Vote extends TxModal { ); } - private setVoteValue = (voteValue?: BN): void => { - this.setState({ voteValue: voteValue || new BN(0) }); + private setVoteValue = (voteValue: BN): void => { + this.setState({ voteValue }); } private fetchApprovals = (accountId: string | null): void => { diff --git a/packages/app-council/src/Overview/VoteValue.tsx b/packages/app-council/src/Overview/VoteValue.tsx index 238cd831b6..b69e32dd33 100644 --- a/packages/app-council/src/Overview/VoteValue.tsx +++ b/packages/app-council/src/Overview/VoteValue.tsx @@ -50,7 +50,7 @@ function VoteValue ({ accountId, allBalances, onChange, t }: Props): React.React } }, [accountId, selectedId, allBalances]); - // only do onChange to parent when the BN value comes in, not our formatted version + // only do onChange to parent when the BN value comes in, not our formatted version useEffect((): void => { isBn(value) && onChange(value); }, [value]); diff --git a/packages/react-components/src/InputBalance.tsx b/packages/react-components/src/InputBalance.tsx index b2175534f8..fe7a9812f1 100644 --- a/packages/react-components/src/InputBalance.tsx +++ b/packages/react-components/src/InputBalance.tsx @@ -34,7 +34,7 @@ const DEFAULT_BITLENGTH = BitLengthOption.CHAIN_SPEC as BitLength; function InputBalance ({ autoFocus, className, defaultValue: inDefault, help, isDisabled, isError, isZeroable, label, labelExtra, maxValue, onChange, onEnter, placeholder, style, value, withEllipsis, withLabel, withMax }: Props): React.ReactElement { const defaultValue = inDefault - ? formatBalance(value, { forceUnit: '-', withSi: false }) + ? formatBalance(inDefault, { forceUnit: '-', withSi: false }).replace(',', isDisabled ? ',' : '') : inDefault; return (