diff --git a/packages/wallet-webui/src/screens/DepositScreen.tsx b/packages/wallet-webui/src/screens/DepositScreen.tsx index 7a4e58b6d..87462f611 100644 --- a/packages/wallet-webui/src/screens/DepositScreen.tsx +++ b/packages/wallet-webui/src/screens/DepositScreen.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState } from "preact/hooks"; +import { useEffect, useMemo, useRef, useState } from "preact/hooks"; import { Button } from "../ui/Button.js"; import { Card } from "../ui/Card.js"; import { ErrorCard } from "../ui/ErrorCard.js"; @@ -114,6 +114,14 @@ export function DepositScreen(props: { const paytoUri = selected?.paytoUri ?? props.initialPaytoUri ?? ""; const destination = selected?.destination ?? props.initialDestination; const normalizedAmount = positiveAmountValue(currency, amount); + const amountInput = useRef(null); + // Once the accounts have loaded (and again when returning from review), the + // amount is the first thing to enter. Without a destination the user has to + // add a bank account first, so focus is left alone then. + const amountFirst = !props.loading && !props.review && Boolean(destination); + useEffect(() => { + if (amountFirst) amountInput.current?.focus({ preventScroll: true }); + }, [amountFirst]); return (
@@ -187,6 +195,7 @@ export function DepositScreen(props: {