Skip to content

Commit

Permalink
Merge pull request #1437 from OskarDamkjaer/focus_editor_on_click
Browse files Browse the repository at this point in the history
Focus reusable editor on mounting it
  • Loading branch information
OskarDamkjaer authored Jun 16, 2021
2 parents 2458c7b + 531477a commit cb55ab5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/browser/modules/Frame/FrameEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ function FrameTitlebar({
}
})

useEffect(() => {
if (renderEditor) {
editorRef.current?.focus()

// Jump cursor to end
const lines = (editorRef.current?.getValue() || '').split('\n')
const linesLength = lines.length
editorRef.current?.setPosition({
lineNumber: linesLength,
column: lines[linesLength - 1].length + 1
})
}
}, [renderEditor])

// the last run command (history index 1) is already in the editor
// don't show it as history as well
const history = (frame.history || []).slice(1)
Expand Down

0 comments on commit cb55ab5

Please sign in to comment.