mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Focus the editor after using the "Switch to editor" button (#21549)
GitOrigin-RevId: f94c6d266ec9c2c3e4a30ea2c34c937817b48596
This commit is contained in:
parent
09ad023161
commit
a827f8835b
2 changed files with 10 additions and 0 deletions
|
@ -20,6 +20,9 @@ function SwitchToEditorButton() {
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
setView('editor')
|
setView('editor')
|
||||||
|
window.setTimeout(() => {
|
||||||
|
window.dispatchEvent(new Event('editor:focus'))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -576,6 +576,13 @@ function useCodeMirrorScope(view: EditorView) {
|
||||||
|
|
||||||
useEventListener('learnedWords:reset', handleResetLearnedWords)
|
useEventListener('learnedWords:reset', handleResetLearnedWords)
|
||||||
|
|
||||||
|
useEventListener(
|
||||||
|
'editor:focus',
|
||||||
|
useCallback(() => {
|
||||||
|
view.focus()
|
||||||
|
}, [view])
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
view.dispatch(reviewPanelToggled())
|
view.dispatch(reviewPanelToggled())
|
||||||
}, [reviewPanelOpen, miniReviewPanelVisible, view])
|
}, [reviewPanelOpen, miniReviewPanelVisible, view])
|
||||||
|
|
Loading…
Reference in a new issue