2
0
Files
bot/apps/builder/src/helpers/focusInput.ts

13 lines
262 B
TypeScript
Raw Normal View History

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