Skip to content

Commit a4795fb

Browse files
authored
Merge pull request #2097 from Urgau/gha-logs-improv-scroll
Improve automatic GHA logs scrolling for desktop and mobile
2 parents e55e881 + c579cb8 commit a4795fb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/gha_logs.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ async fn process_logs(
150150
.timestamp:hover {{
151151
text-decoration: underline;
152152
}}
153+
.error-marker {{
154+
scroll-margin-bottom: 15vh;
155+
}}
153156
</style>
154157
<script type="module" nonce="{nonce}">
155158
import {{ AnsiUp }} from '{ANSI_UP_URL}'
@@ -174,7 +177,7 @@ async fn process_logs(
174177
// 4. Add a anchor around every "##[error]" string
175178
let errorCounter = -1;
176179
html = html.replace(/##\[error\]/g, () =>
177-
`<a id="error-${{++errorCounter}}">##[error]</a>`
180+
`<a id="error-${{++errorCounter}}" class="error-marker">##[error]</a>`
178181
);
179182
180183
// 5. Add the html to the DOM
@@ -183,9 +186,11 @@ async fn process_logs(
183186
184187
// 6. If no anchor is given, scroll to the last error
185188
if (location.hash === "" && errorCounter >= 0) {{
189+
const hasSmallViewport = window.innerWidth <= 750;
186190
document.getElementById(`error-${{errorCounter}}`).scrollIntoView({{
187-
behavior: 'smooth',
188-
block: 'center'
191+
behavior: 'instant',
192+
block: 'end',
193+
inline: hasSmallViewport ? 'start' : 'center'
189194
}});
190195
}}
191196
</script>

0 commit comments

Comments
 (0)