From 2ebb83418c430864b0d0c1510f9a5637ed60eec0 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 9 Sep 2022 00:02:06 -0500 Subject: [PATCH] bet panel: disable input focus on mobile --- web/components/bet-panel.tsx | 13 +++++-------- web/lib/util/device.ts | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index a59d56f2..ce36cdf9 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -41,6 +41,7 @@ import { PillButton } from './buttons/pill-button' import { YesNoSelector } from './yes-no-selector' import { PlayMoneyDisclaimer } from './play-money-disclaimer' import { AlertBox } from './alert-box' +import { isAndroid, isIOS } from 'web/lib/util/device' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -184,17 +185,13 @@ function BuyPanel(props: { const [inputRef, focusAmountInput] = useFocus() - // useEffect(() => { - // if (selected) { - // if (isIOS()) window.scrollTo(0, window.scrollY + 200) - // focusAmountInput() - // } - // }, [selected, focusAmountInput]) - function onBetChoice(choice: 'YES' | 'NO') { setOutcome(choice) setWasSubmitted(false) - focusAmountInput() + + if (!isIOS() && !isAndroid()) { + focusAmountInput() + } } function onBetChange(newAmount: number | undefined) { diff --git a/web/lib/util/device.ts b/web/lib/util/device.ts index 20eabf75..8251d06c 100644 --- a/web/lib/util/device.ts +++ b/web/lib/util/device.ts @@ -12,3 +12,7 @@ export function isIOS() { (navigator.userAgent.includes('Mac') && 'ontouchend' in document) ) } + +export function isAndroid() { + return navigator.userAgent.includes('Android') +} \ No newline at end of file