diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 109cddc2..14acaaa0 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -37,6 +37,7 @@ import { import { SellRow } from './sell-row' import { useSaveShares } from './use-save-shares' import { SignUpPrompt } from './sign-up-prompt' +import { isIOS } from 'web/lib/util/device' export function BetPanel(props: { contract: BinaryContract @@ -203,7 +204,10 @@ function BuyPanel(props: { const [inputRef, focusAmountInput] = useFocus() useEffect(() => { - if (selected) focusAmountInput() + if (selected) { + if (isIOS()) window.scrollTo(0, window.scrollY + 200) + focusAmountInput() + } }, [selected, focusAmountInput]) function onBetChoice(choice: 'YES' | 'NO') { diff --git a/web/lib/util/device.ts b/web/lib/util/device.ts new file mode 100644 index 00000000..20eabf75 --- /dev/null +++ b/web/lib/util/device.ts @@ -0,0 +1,14 @@ +export function isIOS() { + return ( + [ + 'iPad Simulator', + 'iPhone Simulator', + 'iPod Simulator', + 'iPad', + 'iPhone', + 'iPod', + ].includes(navigator.platform) || + // iPad on iOS 13 detection + (navigator.userAgent.includes('Mac') && 'ontouchend' in document) + ) +}