From 75f2eecbbb591cddc03ee23c73319b91733410d1 Mon Sep 17 00:00:00 2001 From: L-Sun Date: Mon, 7 Jul 2025 12:13:15 +0800 Subject: [PATCH] fix(editor): focus comment editor after click its bottom area (#13060) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### PR Dependency Tree * **PR #13060** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **Refactor** * Improved the comment editor's focus behavior to place the cursor at the end of the content when clicking inside the editor. --- .../core/src/components/comment/comment-editor/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/frontend/core/src/components/comment/comment-editor/index.tsx b/packages/frontend/core/src/components/comment/comment-editor/index.tsx index d39504eea..4ca60041b 100644 --- a/packages/frontend/core/src/components/comment/comment-editor/index.tsx +++ b/packages/frontend/core/src/components/comment/comment-editor/index.tsx @@ -1,6 +1,6 @@ import { LitDocEditor, type PageEditor } from '@affine/core/blocksuite/editors'; import { SnapshotHelper } from '@affine/core/modules/comment/services/snapshot-helper'; -import type { RichText } from '@blocksuite/affine/rich-text'; +import { focusTextModel, type RichText } from '@blocksuite/affine/rich-text'; import { ViewportElementExtension } from '@blocksuite/affine/shared/services'; import { type DocSnapshot, Store } from '@blocksuite/affine/store'; import { ArrowUpBigIcon } from '@blocksuite/icons/rc'; @@ -175,7 +175,10 @@ export const CommentEditor = forwardRef( (e: React.MouseEvent) => { e.stopPropagation(); if (editorRef.current) { - editorRef.current.focus(); + const lastChild = editorRef.current.std.store.root?.lastChild(); + if (lastChild) { + focusTextModel(editorRef.current.std, lastChild.id); + } } }, [editorRef]