Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix focus last node on tap bottom area on mobile (#2148)

Ammar Ahmed5e33cb93c663
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index fd990fdd5..ac450d20e 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -155,7 +155,7 @@ const Tiptap = ({
const isFirstChildEmpty =
!firstChild?.textContent || firstChild?.textContent?.length === 0;
if (isParagraph && isFirstChildEmpty) {
- globalThis.editor?.commands.focus();
+ globalThis.editor?.commands.focus("end");
return;
}
globalThis.editor
@@ -163,10 +163,8 @@ const Tiptap = ({
.insertContentAt(0, "<p></p>", {
updateSelection: true
})
+ .focus("end")
.run();
- setTimeout(() => {
- globalThis.editor?.commands.focus();
- }, 1);
}
},
[]
@@ -180,7 +178,7 @@ const Tiptap = ({
const isLastChildEmpty =
!lastChild?.textContent || lastChild?.textContent?.length === 0;
if (isParagraph && isLastChildEmpty) {
- globalThis.editor?.commands.focus();
+ globalThis.editor?.commands.focus("end");
return;
}
globalThis.editor
@@ -188,10 +186,8 @@ const Tiptap = ({
.insertContentAt(docSize - 1, "<p></p>", {
updateSelection: true
})
+ .focus("end")
.run();
- setTimeout(() => {
- globalThis.editor?.commands.focus();
- }, 1);
}, []);
return (