Skip to content

Commit 60564e2

Browse files
authored
fix log anchoring in small stage logs (jenkinsci#762)
1 parent 9185594 commit 60564e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogStream.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ export default function ConsoleLogStream(props: ConsoleLogStreamProps) {
7373
return props.step.state === Result.running || props.logBuffer.startByte < 0;
7474
};
7575

76+
useEffect(() => {
77+
const hash = window.location.hash;
78+
if (!hash.startsWith("#log-")) {
79+
return;
80+
}
81+
const lineNumber = parseInt(hash.substring(5));
82+
if (!(!isNaN(lineNumber) && virtuosoRef.current)) {
83+
return;
84+
}
85+
virtuosoRef.current.scrollToIndex({
86+
index: lineNumber,
87+
align: "center",
88+
});
89+
}, []);
90+
7691
return (
7792
<Virtuoso
7893
useWindowScroll

0 commit comments

Comments
 (0)