From f602561323092cd750b5cf141b34cb8a7c140c32 Mon Sep 17 00:00:00 2001 From: jahooma Date: Fri, 10 Dec 2021 10:04:59 -0600 Subject: [PATCH] Tweak bet input to let you clear 0. --- web/components/bet-panel.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 36c1f83d..7b1bd550 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -11,6 +11,11 @@ export function BetPanel(props: { contract: Contract; className?: string }) { const [betChoice, setBetChoice] = useState<'YES' | 'NO'>('YES') const [betAmount, setBetAmount] = useState(undefined) + function onBetChange(str: string) { + const amount = parseInt(str) + setBetAmount(isNaN(amount) ? undefined : amount) + } + return (
Pick outcome
@@ -31,9 +36,8 @@ export function BetPanel(props: { contract: Contract; className?: string }) { style={{ maxWidth: 80 }} type="text" placeholder="0" - value={betAmount} - onChange={(e) => setBetAmount(parseInt(e.target.value) || 0)} - onFocus={(e) => e.target.select()} + value={betAmount ?? ''} + onChange={(e) => onBetChange(e.target.value)} />
points