Revanth14 commented on code in PR #64013:
URL: https://github.com/apache/airflow/pull/64013#discussion_r3309470182
##########
airflow/www/static/js/dag/details/taskInstance/Logs/LogBlock.tsx:
##########
@@ -35,25 +40,53 @@ const LogBlock = ({
setUnfoldedLogGroup,
}: Props) => {
const [autoScroll, setAutoScroll] = useState(true);
+ const [logHeight, setLogHeight] = useState<number>();
const logBoxRef = useRef<HTMLPreElement>(null);
- const offsetTop = useOffsetTop(logBoxRef);
+
+ const resizeLogBlock = useCallback(() => {
+ requestAnimationFrame(() => {
+ const logBox = logBoxRef.current;
+ if (!logBox) return;
+
+ const footerHeight =
+ parseInt(getComputedStyle(document.body).paddingBottom, 10) || 0;
+ const viewportHeight = window.visualViewport?.height ??
window.innerHeight;
+ const { top } = logBox.getBoundingClientRect();
+
+ setLogHeight(Math.max(0, viewportHeight - top - footerHeight));
+ });
+ }, []);
const scrollToBottom = () => {
- if (logBoxRef.current) {
- logBoxRef.current.scrollTop = logBoxRef.current.scrollHeight;
- }
+ requestAnimationFrame(() => {
+ if (logBoxRef.current) {
+ logBoxRef.current.scrollTop = logBoxRef.current.scrollHeight;
+ }
+ });
};
+ useLayoutEffect(() => {
+ resizeLogBlock();
+
+ window.addEventListener("resize", resizeLogBlock);
+ window.visualViewport?.addEventListener("resize", resizeLogBlock);
+
+ return () => {
+ window.removeEventListener("resize", resizeLogBlock);
+ window.visualViewport?.removeEventListener("resize", resizeLogBlock);
+ };
+ }, [resizeLogBlock, wrap, parsedLogs]);
Review Comment:
Addressed. Resize listener registration is now split into a mount/unmount
effect with `[resizeLogBlock]`, and layout recalculation runs separately when
`wrap` changes.
--
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]