fix: prevent log loading from scrolling ancestor elements in task Logs tab#64889
fix: prevent log loading from scrolling ancestor elements in task Logs tab#64889Pyasma wants to merge 1 commit intoapache:v2-11-testfrom
Conversation
|
|
||
| // For an html element, keep it within view height by calculating the top offset and footer height | ||
| const useOffsetTop = (contentRef: React.RefObject<HTMLElement>) => { | ||
| const useOffsetTop = (contentRef: React.RefObject<HTMLElement | null>) => { |
There was a problem hiding this comment.
Nit: This seems unrelated to the change.
There was a problem hiding this comment.
hey @pierrejeambrun these changes were suggested by Claude code I wasn't able to reproduce the issue on my end before
I just finished with the problem of reproducing
will push the changes soon
There was a problem hiding this comment.
sure i will also add the video to show the After and Before changes
There was a problem hiding this comment.
Pull request overview
Fixes an Airflow UI scrolling bug in the Task Instance Logs tab where auto-scrolling to the bottom of loaded logs was inadvertently scrolling ancestor containers (e.g., the task details panel), not just the log viewport.
Changes:
- Replace
scrollIntoView()on a sentinel element with directscrollTopmanipulation on the log container to constrain scrolling to the log box. - Remove the now-unnecessary bottom sentinel
<div>from the log markup. - Broaden
useOffsetTop’s ref parameter type to better support refs initialized withnullunder newer React/TypeScript typings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
airflow/www/static/js/dag/details/taskInstance/Logs/LogBlock.tsx |
Ensures “scroll to bottom” only scrolls the log container by setting scrollTop directly and removing the sentinel element. |
airflow/www/static/js/utils/useOffsetTop.ts |
Adjusts hook ref typing to accept null within the generic, aligning with newer React/TS ref patterns. |
Closes: #64757
Problem
When switching to the Logs tab on a task with many log lines, the entire details panel scrolls irreversibly instead of just the log box.
Root cause:
scrollToBottom()calledscrollIntoView()on a sentinel<div>at the bottom of log content.scrollIntoViewwalks up the DOM tree scrolling every ancestor element until the target is visible — sodiv.c-5s5pdh(the details panel) was being scrolled, not just the log box.Fix
LogBlock.tsx<div dangerouslySetInnerHTML={{ __html: parsedLogs }} /> - <div ref={codeBlockBottomDiv} />scrollTop = scrollHeightsets the scroll position directly on the log box element only. Nothing outside it moves.useOffsetTop.tsUpdated parameter type to accept
nullinside the generic — required becauseuseRef<HTMLElement>(null)now returnsRefObject<HTMLElement | null>in newer React/TypeScript versions.Was generative AI tooling used to co-author this PR?