diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useEditorSearch.ts b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useEditorSearch.ts index c7f6a8266f..970e56f9bf 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useEditorSearch.ts +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useEditorSearch.ts @@ -64,7 +64,7 @@ export default function useEditorSearch(CodeMirror: any) { } if (match) { - if (scrollTo) cm.setSelection(match.from, match.to); + if (scrollTo) cm.scrollIntoView(match); return cm.markText(match.from, match.to, { className: 'cm-search-marker-selected' }); } diff --git a/packages/app-desktop/gui/NoteEditor/utils/useNoteSearchBar.ts b/packages/app-desktop/gui/NoteEditor/utils/useNoteSearchBar.ts index 4821174c5e..ecbd6d0014 100644 --- a/packages/app-desktop/gui/NoteEditor/utils/useNoteSearchBar.ts +++ b/packages/app-desktop/gui/NoteEditor/utils/useNoteSearchBar.ts @@ -1,7 +1,6 @@ import { useState, useCallback } from 'react'; import Logger from '@joplin/lib/Logger'; import { SearchMarkers } from './useSearchMarkers'; -const CommandService = require('@joplin/lib/services/CommandService').default; const logger = Logger.create('useNoteSearchBar'); @@ -71,7 +70,6 @@ export default function useNoteSearchBar() { const onClose = useCallback(() => { setShowLocalSearch(false); setLocalSearch(defaultLocalSearch()); - void CommandService.instance().execute('focusElementNoteBody'); }, []); const setResultCount = useCallback((count: number) => {