fix: improve tag insertion position in memo editor

- Add scroll to cursor functionality after tag insertion
- Enhance user experience by showing newly added tags

Signed-off-by: ChaoLiu <chaoliu719@gmail.com>
This commit is contained in:
ChaoLiu 2025-08-18 18:07:46 +08:00
parent 30202db710
commit 855cb06018
1 changed files with 6 additions and 0 deletions

View File

@ -488,6 +488,9 @@ const MemoEditor = observer((props: Props) => {
editorRef.current.insertText("\n");
editorRef.current.insertText(`#${tag} `);
// Scroll to the bottom to show the newly added tag
editorRef.current.scrollToCursor();
// Remove the tag from recommendations after adding it
setState((prevState) => ({
...prevState,
@ -514,6 +517,9 @@ const MemoEditor = observer((props: Props) => {
const tagsText = state.recommendedTags.map((tagSuggestion) => `#${tagSuggestion.tag}`).join(" ") + " ";
editorRef.current.insertText(tagsText);
// Scroll to the bottom to show the newly added tags
editorRef.current.scrollToCursor();
// Clear recommendations
setState((prevState) => ({
...prevState,