fix: remove disabling on send input click

This commit is contained in:
alter-eggo
2023-06-07 12:46:57 +04:00
committed by kyranjamie
parent 7af5e8afb7
commit 1b049e52ca
3 changed files with 15 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ interface AmountFieldProps {
isSendingMax?: boolean;
switchableAmount?: React.JSX.Element;
tokenSymbol?: string;
onSetIsSendingMax?(value: boolean): void;
}
export function AmountField({
autoComplete = 'on',
@@ -45,10 +46,11 @@ export function AmountField({
balance,
bottomInputOverlay,
isSendingMax,
onSetIsSendingMax,
switchableAmount,
tokenSymbol,
}: AmountFieldProps) {
const [field, meta] = useField('amount');
const [field, meta, helpers] = useField('amount');
const [fontSize, setFontSize] = useState(maxFontSize);
const [previousTextLength, setPreviousTextLength] = useState(1);
@@ -89,8 +91,16 @@ export function AmountField({
// TODO: could be implemented with html using padded label element
const onClickFocusInput = useCallback(() => {
document.getElementById(amountInputId)?.focus();
}, []);
if (isSendingMax) {
helpers.setValue('');
onSetIsSendingMax?.(false);
}
// put focus in the queue, otherwise it won't work
setTimeout(() => {
document.getElementById(amountInputId)?.focus();
});
}, [isSendingMax, helpers, onSetIsSendingMax]);
return (
<Stack

View File

@@ -58,7 +58,7 @@ export function BitcoinSendMaxButton({
width="fit-content"
{...props}
>
Sending max
{isSendingMax ? 'Sending max' : 'Send max'}
</Button>
</Tooltip>
);

View File

@@ -73,6 +73,7 @@ export function BtcSendForm() {
sendMaxFee={sendMaxCalculation.spendAllFee.toString()}
/>
}
onSetIsSendingMax={onSetIsSendingMax}
isSendingMax={isSendingMax}
switchableAmount={
<SendFiatValue marketData={btcMarketData} assetSymbol={'BTC'} />