13 lines
262 B
TypeScript
13 lines
262 B
TypeScript
|
|
type Props = {
|
||
|
|
at: number
|
||
|
|
input?: HTMLInputElement | HTMLTextAreaElement | null
|
||
|
|
}
|
||
|
|
|
||
|
|
export const focusInput = ({ at, input }: Props) => {
|
||
|
|
if (!input) return
|
||
|
|
input.focus()
|
||
|
|
setTimeout(() => {
|
||
|
|
input.selectionStart = input.selectionEnd = at
|
||
|
|
}, 100)
|
||
|
|
}
|