Unverified Commit 942e1f88 authored by Stephen Zhou's avatar Stephen Zhou Committed by GitHub

feat: scrool to memo after editing (#907)

parent b8ab43aa
......@@ -295,6 +295,15 @@ const MemoEditor = () => {
return resource;
};
const scrollToEditingMemo = useCallback(() => {
if (editorState.editMemoId) {
const memoElements = document.getElementsByClassName(`memos-${editorState.editMemoId}`);
if (memoElements.length !== 0) {
memoElements[0].scrollIntoView({ behavior: "smooth" });
}
}
}, [editorState.editMemoId]);
const handleSaveBtnClick = async () => {
const content = editorRef.current?.getContent() ?? "";
try {
......@@ -341,6 +350,8 @@ const MemoEditor = () => {
setEditorContentCache("");
storage.remove(["editingMemoVisibilityCache"]);
editorRef.current?.setContent("");
scrollToEditingMemo();
};
const handleCancelEdit = () => {
......@@ -351,6 +362,8 @@ const MemoEditor = () => {
setEditorContentCache("");
storage.remove(["editingMemoVisibilityCache"]);
}
scrollToEditingMemo();
};
const handleContentChange = (content: string) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment