@@ -188,11 +188,22 @@ const sfc = {
188
188
},
189
189
190
190
appendLogs (stepIndex , logLines , startTime ) {
191
+ // position of the client view relative to the website top
192
+ const clientHeight = document .documentElement .clientHeight + window .scrollY ;
193
+ // height of the logs container relative to the website top
194
+ const logsContainerHeight = this .$refs .stepsContainer .getBoundingClientRect ().bottom + window .scrollY ;
195
+
191
196
for (const line of logLines) {
192
197
// TODO: group support: ##[group]GroupTitle , ##[endgroup]
193
198
const el = this .getLogsContainer (stepIndex);
194
199
el .append (this .createLogLine (line, startTime, stepIndex));
195
200
}
201
+
202
+ // scrolls to the bottom if job is running and the bottom of the logs container is visible
203
+ if (! this .run .done && logLines .length > 0 && clientHeight >= logsContainerHeight) {
204
+ const newLogsContainerHeight = this .$refs .stepsContainer .getBoundingClientRect ().bottom + window .scrollY ;
205
+ window .scrollTo ({top: clientHeight + (newLogsContainerHeight - logsContainerHeight), behavior: ' smooth' });
206
+ }
196
207
},
197
208
198
209
async fetchArtifacts () {
@@ -424,7 +435,7 @@ export function initRepositoryActionView() {
424
435
< / div>
425
436
< / div>
426
437
427
- < div class = " action-view-right" >
438
+ < div class = " action-view-right" ref = " stepsContainer " >
428
439
< div class = " job-info-header" >
429
440
< div class = " job-info-header-left" >
430
441
< h3 class = " job-info-header-title" >
0 commit comments