diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index a6fbce5d..b03bea4f 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -1102,7 +1102,10 @@ export const EditorPane = (props: EditorPaneProps) => { return ( { if (props.memo?.id && !readOnly) { setMobileNativeEditMemoId(props.memo.id); @@ -1263,12 +1266,18 @@ const RichEditorPane = ({ } const currentEditor = editorRef.current; - if (!isMobileViewport && isEditorReady(currentEditor)) { - currentEditor.commands.focus("end"); - return; + if (!isMobileViewport) { + if (isEditorReady(currentEditor) && hydratedMemoIdRef.current === memo.id) { + currentEditor.commands.focus("end"); + onMobileDefaultEditConsumed(); + return; + } } - if (attempt < 10) { + // The editor is mounted before its memo hydration/edit session + // finishes. Keep retrying across that async boundary so a newly + // created note reliably receives the caret on desktop as well. + if (attempt < 120) { focusWhenReady(attempt + 1); return; } diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx index 4c10f68e..67a79f00 100644 --- a/apps/web/src/components/WorkspaceApp.tsx +++ b/apps/web/src/components/WorkspaceApp.tsx @@ -1301,9 +1301,9 @@ export const WorkspaceApp = ({ const selectedMemoInList = selectedMemoId ? memos.some((memo) => memo.id === selectedMemoId) : false; if (createdMemoEditId && selectedMemoId === createdMemoEditId) { - if (selectedMemoInList) { - setCreatedMemoEditId(null); - } + // Keep the create request alive until the editor consumes it. The new + // memo can appear in the list before its detail query has mounted the + // editor, and clearing it here would lose the autofocus request. return; } diff --git a/package.json b/package.json index 6acc7b33..5c91127e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edgeever", - "version": "1.6.16", + "version": "1.6.17", "private": true, "type": "module", "workspaces": [