pierrejeambrun commented on code in PR #60806:
URL: https://github.com/apache/airflow/pull/60806#discussion_r2708516244


##########
.gitignore:
##########
@@ -15,6 +15,7 @@ airflow-core/src/airflow/ui/coverage/
 airflow/git_version
 airflow/ui/coverage/
 logs/
+!airflow-core/src/airflow/ui/**/Logs/

Review Comment:
   I don't think that's relevant to the PR, we should remove it.



##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -92,14 +99,55 @@ export const TaskLogContent = ({ error, isLoading, 
logError, parsedLogs, wrap }:
   const showScrollButtons = parsedLogs.length > 1 && contentHeight > 
containerHeight;
 
   useLayoutEffect(() => {
-    if (location.hash && !isLoading) {
-      rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, 
parsedLogs.length - 1));
+    if (
+      initialHashRef.current === undefined ||
+      hasScrolledRef.current ||
+      isLoading ||
+      parsedLogs.length === 0
+    ) {
+      return;
+    }
+
+    hasScrolledRef.current = true;
+
+    const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, 
Number(hash) || 0));
+    const el = parentRef.current;
+
+    if (!el) {
+      rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+
+      return;
     }
+
+    const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => 
virtualRow.index === targetIndex);
+    const approxPerItem = 20;
+    const targetPosition = vItem?.start ?? targetIndex * approxPerItem;

Review Comment:
   I don't think this is working well if the logs are wrapped.
   
   I would keep this as a follow up PR, so we can focus this one on fixing the 
scroll to top / bottom issue. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to