diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 9872079a..429785b9 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -150,6 +150,7 @@ const MarkdownTextInput = React.forwardRef( spellCheck, style = {}, value, + autoFocus = false, }, ref, ) => { @@ -500,6 +501,14 @@ const MarkdownTextInput = React.forwardRef( }; }, []); + useEffect(() => { + // focus the input on mount if autoFocus is set + if (!(divRef.current && autoFocus)) { + return; + } + divRef.current.focus(); + }, []); + return ( // eslint-disable-next-line jsx-a11y/no-static-element-interactions