2
0
Files
bot/apps/builder/src/helpers/focusInput.ts
2023-03-15 11:52:38 +01:00

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)
}