فهرست منبع

Merge branch 'agile' of github.com:iapt-platform/mint into agile

Jeremy Zheng 2 سال پیش
والد
کامیت
437526f524

+ 4 - 1
dashboard/src/components/discussion/DiscussionTopicChildren.tsx

@@ -46,7 +46,10 @@ const DiscussionTopicChildrenWidget = ({
   useEffect(() => {
     if (loading === false) {
       const ele = document.getElementById(`answer-${focus}`);
-      ele?.scrollIntoView();
+      ele?.scrollIntoView({
+        behavior: "smooth",
+        block: "center",
+      });
       console.log("after render");
     }
   });

+ 7 - 1
dashboard/src/components/template/SentEdit/SentCell.tsx

@@ -60,7 +60,13 @@ const SentCellWidget = ({
   useEffect(() => {
     if (anchorInfo && anchorInfo?.resId === initValue?.id) {
       const ele = document.getElementById(sid);
-      ele?.scrollIntoView();
+      if (ele !== null) {
+        ele.scrollIntoView({
+          behavior: "smooth",
+          block: "center",
+          inline: "nearest",
+        });
+      }
     }
   }, [anchorInfo, initValue?.id, sid]);
 

+ 6 - 1
dashboard/src/pages/library/article/show.tsx

@@ -122,8 +122,11 @@ const Widget = () => {
     currMode = "read";
   }
   console.log(anchorNavOpen, anchorNavShow);
+  const scrollToTop = () => {
+    document.getElementById("article-root")?.scrollIntoView();
+  };
   return (
-    <div>
+    <div id="article-root">
       <Affix offsetTop={0}>
         <Header
           style={{
@@ -263,6 +266,7 @@ const Widget = () => {
                       param.push(`${key}=${value}`);
                     });
                     navigate(url + param.join("&"));
+                    scrollToTop();
                   }}
                 />
                 <ToolButtonNav type={type} articleId={id} />
@@ -360,6 +364,7 @@ const Widget = () => {
                   window.open(fullUrl(url), "_blank");
                 } else {
                   navigate(url);
+                  scrollToTop();
                 }
               }}
             />