Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: memo list auto scroll to top (#313)

boojack35a881744211
diff --git a/web/src/components/Editor/Editor.tsx b/web/src/components/Editor/Editor.tsx
index a96e313a7..38a7cc868 100644
--- a/web/src/components/Editor/Editor.tsx
+++ b/web/src/components/Editor/Editor.tsx
@@ -29,6 +29,7 @@ const Editor = forwardRef((props: Props, ref: React.ForwardedRef<EditorRefAction
useEffect(() => {
if (editorRef.current && initialContent) {
editorRef.current.value = initialContent;
+ handleContentChangeCallback(initialContent);
}
}, []);
diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx
index 27c456ed7..702e2a087 100644
--- a/web/src/components/MemoList.tsx
+++ b/web/src/components/MemoList.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef } from "react";
+import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { memoService, shortcutService } from "../services";
import { useAppSelector } from "../store";
@@ -13,7 +13,6 @@ const MemoList = () => {
const { t } = useTranslation();
const query = useAppSelector((state) => state.location.query);
const { memos, isFetching } = useAppSelector((state) => state.memo);
- const wrapperElement = useRef<HTMLDivElement>(null);
const { tag: tagQuery, duration, type: memoType, text: textQuery, shortcutId } = query ?? {};
const shortcut = shortcutId ? shortcutService.getShortcutById(shortcutId) : null;
@@ -86,13 +85,14 @@ const MemoList = () => {
}, []);
useEffect(() => {
- wrapperElement.current?.scrollTo({
- top: 0,
- });
+ const pageWrapper = document.body.querySelector(".page-wrapper");
+ if (pageWrapper) {
+ pageWrapper.scrollTo(0, 0);
+ }
}, [query]);
return (
- <div className="memo-list-container" ref={wrapperElement}>
+ <div className="memo-list-container">
{sortedMemos.map((memo) => (
<Memo key={`${memo.id}-${memo.createdTs}-${memo.updatedTs}`} memo={memo} />
))}