diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a289758..76b396657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Fix Tooltip styles [#1944](https://github.com/thorchain/asgardex-electron/pull/1944) - [Swap] Limits added to memo needs to be 1e8 [#1946](https://github.com/thorchain/asgardex-electron/issues/1946) - [PoolShare] Don't combine `asym` with `sym` shares in PoolShare [#1964](https://github.com/thorchain/asgardex-electron/pull/1964) +- [Send] Fix max value for sending ETH [#1978](https://github.com/thorchain/asgardex-electron/pull/1978) ## Internal diff --git a/src/renderer/components/wallet/txs/send/SendFormETH.tsx b/src/renderer/components/wallet/txs/send/SendFormETH.tsx index 1491e78b3..e05916511 100644 --- a/src/renderer/components/wallet/txs/send/SendFormETH.tsx +++ b/src/renderer/components/wallet/txs/send/SendFormETH.tsx @@ -169,7 +169,12 @@ export const SendFormETH: React.FC = (props): JSX.Element => { ) const renderFeeOptions = useMemo(() => { - const onChangeHandler = (e: RadioChangeEvent) => setSelectedFeeOption(e.target.value) + const onChangeHandler = (e: RadioChangeEvent) => { + // Change amount back to `none` (ZERO) whenever selected fee is changed + // Just to avoid using a previous `max` value, which can be invalid now + setAmountToSend(O.none) + setSelectedFeeOption(e.target.value) + } const disabled = !feesAvailable || isLoading return ( @@ -216,13 +221,19 @@ export const SendFormETH: React.FC = (props): JSX.Element => { }, [selectedFee, oEthAmount, balance]) useEffect(() => { - // Whenever `amountToSend` has been updated, we put it back into input field FP.pipe( amountToSend, - O.map((amount) => - form.setFieldsValue({ - amount: baseToAsset(amount).amount() - }) + O.fold( + // reset value to ZERO whenever amount is not set + () => + form.setFieldsValue({ + amount: ZERO_BN + }), + // Whenever `amountToSend` has been updated, we put it back into input field + (amount) => + form.setFieldsValue({ + amount: baseToAsset(amount).amount() + }) ) ) }, [amountToSend, form])