Fix InputBalance default display (#1880)

This commit is contained in:
Jaco Greeff 2019-11-14 11:44:40 +01:00 committed by GitHub
parent 6a92aea32b
commit be039f9d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -243,8 +243,8 @@ class Vote extends TxModal<Props, State> {
);
}
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 => {

View File

@ -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]);

View File

@ -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<Props> {
const defaultValue = inDefault
? formatBalance(value, { forceUnit: '-', withSi: false })
? formatBalance(inDefault, { forceUnit: '-', withSi: false }).replace(',', isDisabled ? ',' : '')
: inDefault;
return (