2
0

fix(bot): mobile keyboard covering input

This commit is contained in:
Baptiste Arnaud
2022-07-17 18:20:53 +02:00
parent b62b955c07
commit f1a01bf663
2 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import React, {
useRef,
} from 'react'
import PhoneInput, { Value, Country } from 'react-phone-number-input'
import { isMobile } from 'services/utils'
type TextInputProps = {
block:
@ -30,8 +31,7 @@ export const TextInput = ({ block, value, onChange }: TextInputProps) => {
const inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null)
useEffect(() => {
if (!inputRef.current) return
inputRef.current.focus()
setTimeout(() => inputRef.current?.focus(), isMobile ? 500 : 0)
}, [])
const handleInputChange = (

View File

@ -5,3 +5,7 @@ export const sanitizeUrl = (url: string): string =>
url.startsWith('sms:')
? url
: `https://${url}`
export const isMobile =
typeof window !== 'undefined' &&
window.matchMedia('only screen and (max-width: 760px)').matches