Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

refac: focus on input when mount in remove liquidity page #110

Merged
merged 1 commit into from
May 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions client/src/pages/PoolPage/RemoveLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { Link } from "src/components/Link";
import { Pages } from "src/types/pages";
import coins from "src/lib/CoinsMetadata";
import { useContract, useWallet } from "src/context/AppContext";
import { useEffect, useRef } from "react";

export default function RemoveLiquidityPage() {
const liquidityToken = coins.find((c) => c.assetId === CONTRACT_ID);
const wallet = useWallet()!;
const contract = useContract()!;
const navigate = useNavigate();
const firstInputRef = useRef<HTMLInputElement | null>(null);

const liquidityToken = coins.find((c) => c.assetId === CONTRACT_ID);
const tokenInput = useCoinInput({ coin: liquidityToken });
const amount = tokenInput.amount;

Expand Down Expand Up @@ -59,14 +61,18 @@ export default function RemoveLiquidityPage() {
}
);

useEffect(() => {
firstInputRef.current?.focus();
}, []);

if (!liquidityToken) {
return null;
}

return (
<>
<div className="mt-4 mb-4">
<CoinInput {...tokenInput.getInputProps()} />
<CoinInput {...tokenInput.getInputProps()} ref={firstInputRef} />
<Link
className="inline-flex mt-2 ml-2"
onPress={() => tokenInput.setAmount(balance?.amount!)}
Expand Down