Parcourir la source

fix: autoscroll

Soham Parekh il y a 3 ans
Parent
commit
34a6cb7201

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/LogsSection.tsx

@@ -124,13 +124,13 @@ const LogsSection: React.FC<Props> = ({
   }, []);
 
   useEffect(() => {
-    if (scrollToBottomRef.current && scrollToBottomEnabled) {
+    if (!loading && scrollToBottomRef.current && scrollToBottomEnabled) {
       scrollToBottomRef.current.scrollIntoView({
         behavior: "smooth",
         block: "end",
       });
     }
-  }, [logs, scrollToBottomRef, scrollToBottomEnabled]);
+  }, [loading, logs, scrollToBottomRef, scrollToBottomEnabled]);
 
   const renderLogs = () => {
     return logs?.map((log, i) => {
@@ -257,9 +257,9 @@ const LogsSection: React.FC<Props> = ({
               >
                 Load more
               </LoadMoreButton>
-              <div ref={scrollToBottomRef} />
             </>
           )}
+          <div ref={scrollToBottomRef} />
         </StyledLogsSection>
       </>
     );