jscheffl commented on code in PR #51943:
URL: https://github.com/apache/airflow/pull/51943#discussion_r2159332435
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -42,25 +87,22 @@ export const TaskLogContent = ({ error, isLoading,
logError, parsedLogs, wrap }:
});
useLayoutEffect(() => {
- if (location.hash) {
- const hash = location.hash.replace("#", "");
-
- setTimeout(() => {
- const element = document.querySelector<HTMLElement>(`[id='${hash}']`);
+ if (location.hash && !isLoading) {
+ rowVirtualizer.scrollToIndex(Number(hash));
+ }
+ }, [isLoading, rowVirtualizer, hash]);
- if (element !== null) {
- element.style.background = bgLine as string;
- }
- element?.scrollIntoView({
- behavior: "smooth",
- block: "center",
- });
- }, 100);
+ const handleScrollTo = (to: "bottom" | "top") => {
+ if (parsedLogs.length > 0) {
+ rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 :
0);
}
- }, [isLoading, bgLine]);
+ };
+
+ useHotkeys("ArrowDown", () => handleScrollTo("bottom"), { enabled:
!isLoading });
+ useHotkeys("ArrowUp", () => handleScrollTo("top"), { enabled: !isLoading });
Review Comment:
I see a problem with the used/proposed hotkeys here. This are the regular
"up" and "down" keys which today also are used to scroll through the logs. But
if I use them now it is immediately scrolling to the end.
Usually for such feature a modifier should be used as up and down are
regularly used to scroll within the logs.
Can you add a modified CTRL for example such that CTRL+down is going to the
end? That is a quite common key binding.
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -104,6 +147,9 @@ export const TaskLogContent = ({ error, isLoading,
logError, parsedLogs, wrap }:
))}
</VStack>
</Code>
+
+ <ScrollToButton direction="top" onClick={() => handleScrollTo("top")} />
+ <ScrollToButton direction="bottom" onClick={() =>
handleScrollTo("bottom")} />
Review Comment:
Buttons seem to be always displayed also if the log is short. Can we display
them only when needed (log content is larger than the viewport)?
--
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]