mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
editor: stop focus dragging the view back to the caret on load
This commit is contained in:
@@ -298,7 +298,10 @@ function TipTap(props: TipTapProps) {
|
||||
element: editorContainer(),
|
||||
editable: !readonly,
|
||||
content: content?.(),
|
||||
autofocus: "start",
|
||||
// Tiptap's autofocus scrolls to the caret a frame after the editor is
|
||||
// created, which would undo the restored scroll position. The caret is
|
||||
// placed by the selection restore instead.
|
||||
autofocus: false,
|
||||
onFocus,
|
||||
onCreate: async ({ editor }) => {
|
||||
setProfiledEditor(editor as Editor);
|
||||
|
||||
@@ -70,7 +70,9 @@ export const useEditor = (
|
||||
editor.createView();
|
||||
});
|
||||
}
|
||||
if (oldIsFocused && !editor.isFocused) editor.commands.focus();
|
||||
// Restoring focus must not drag the view to the caret.
|
||||
if (oldIsFocused && !editor.isFocused)
|
||||
editor.commands.focus(null, { scrollIntoView: false });
|
||||
// The Editor constructor emits `create` for the view it made, so calling
|
||||
// the option here as well would run every consumer twice on load.
|
||||
if (!firstRun) options.onCreate?.({ editor: editor });
|
||||
|
||||
Reference in New Issue
Block a user