fix(bot): mobile keyboard covering input
This commit is contained in:
@@ -14,6 +14,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import PhoneInput, { Value, Country } from 'react-phone-number-input'
|
import PhoneInput, { Value, Country } from 'react-phone-number-input'
|
||||||
|
import { isMobile } from 'services/utils'
|
||||||
|
|
||||||
type TextInputProps = {
|
type TextInputProps = {
|
||||||
block:
|
block:
|
||||||
@@ -30,8 +31,7 @@ export const TextInput = ({ block, value, onChange }: TextInputProps) => {
|
|||||||
const inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null)
|
const inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!inputRef.current) return
|
setTimeout(() => inputRef.current?.focus(), isMobile ? 500 : 0)
|
||||||
inputRef.current.focus()
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleInputChange = (
|
const handleInputChange = (
|
||||||
|
|||||||
@@ -5,3 +5,7 @@ export const sanitizeUrl = (url: string): string =>
|
|||||||
url.startsWith('sms:')
|
url.startsWith('sms:')
|
||||||
? url
|
? url
|
||||||
: `https://${url}`
|
: `https://${url}`
|
||||||
|
|
||||||
|
export const isMobile =
|
||||||
|
typeof window !== 'undefined' &&
|
||||||
|
window.matchMedia('only screen and (max-width: 760px)').matches
|
||||||
|
|||||||
Reference in New Issue
Block a user