Skip to content

Commit bd11a80

Browse files
LucasKuhlemannLucas Kuhlemann
andauthored
fix(Logfile): ensure horizontal scrollbar is within the viewport and disabled when wrap lines is enabled, fix autoscroll with non-integer scroll height (#5293)
Co-authored-by: Lucas Kuhlemann <lucas.kuhlemann@mimacom.com>
1 parent 151ae76 commit bd11a80

2 files changed

Lines changed: 49 additions & 9 deletions

File tree

spring-boot-admin-server-ui/src/main/frontend/views/instances/logfile/index.vue

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
-->
1616

1717
<template>
18-
<sba-instance-section :error="error" :loading="!hasLoaded">
18+
<sba-instance-section
19+
:error="error"
20+
:loading="!hasLoaded"
21+
:layout-options="{ isFlex: true, noMargin: true }"
22+
class="logfile-section"
23+
>
1924
<template #before>
2025
<sba-sticky-subnav>
2126
<div class="flex items-center justify-end gap-1">
@@ -86,6 +91,7 @@
8691
</template>
8792

8893
<div
94+
ref="scrollContainer"
8995
:class="{ 'wrap-lines': wrapLines }"
9096
class="log-viewer overflow-x-auto text-sm -mx-6 -my-20 pt-14"
9197
>
@@ -143,17 +149,20 @@ export default {
143149
},
144150
created() {
145151
this.ansiUp = new AnsiUp();
146-
this.scrollSubscription = fromEvent(window, 'scroll')
152+
},
153+
mounted() {
154+
const element = this.$refs.scrollContainer;
155+
this.scrollSubscription = fromEvent(element, 'scroll')
147156
.pipe(
148157
debounceTime(25),
149-
map((event) => event.target.scrollingElement.scrollTop),
158+
map(() => element.scrollTop),
150159
)
151160
.subscribe((scrollTop) => {
152161
this.atTop = scrollTop === 0;
153162
this.atBottom =
154-
document.scrollingElement.clientHeight ===
155-
document.scrollingElement.scrollHeight -
156-
document.scrollingElement.scrollTop;
163+
Math.abs(
164+
element.clientHeight - (element.scrollHeight - element.scrollTop),
165+
) <= 1;
157166
});
158167
},
159168
beforeUnmount() {
@@ -204,11 +213,11 @@ export default {
204213
});
205214
},
206215
scrollToTop() {
207-
document.scrollingElement.scrollTop = 0;
216+
this.$refs.scrollContainer.scrollTop = 0;
208217
},
209218
scrollToBottom() {
210-
document.scrollingElement.scrollTop =
211-
document.scrollingElement.scrollHeight;
219+
this.$refs.scrollContainer.scrollTop =
220+
this.$refs.scrollContainer.scrollHeight;
212221
},
213222
downloadLogfile() {
214223
window.open(`instances/${this.instance.id}/actuator/logfile`, '_blank');
@@ -231,6 +240,35 @@ export default {
231240
232241
<style lang="css">
233242
@reference "../../../index.css";
243+
.logfile-section {
244+
display: flex;
245+
flex-direction: column;
246+
max-height: 100%;
247+
}
248+
249+
.logfile-section #subnavigation {
250+
flex: 0 0 auto;
251+
}
252+
253+
.logfile-section .sba-instance-section-content {
254+
min-height: 0;
255+
padding: 0;
256+
overflow: hidden;
257+
flex-direction: column;
258+
}
259+
260+
.logfile-section .sba-instance-section-content [role='alert'] {
261+
margin: 0;
262+
}
263+
264+
.log-viewer {
265+
overflow: auto;
266+
margin: 0;
267+
padding: 0;
268+
width: 100%;
269+
max-height: 100%;
270+
}
271+
234272
.log-viewer pre {
235273
padding: 0 0.75em;
236274
margin-bottom: 1px;
@@ -242,6 +280,7 @@ export default {
242280
243281
.log-viewer.wrap-lines pre {
244282
@apply whitespace-pre-wrap;
283+
word-break: break-all;
245284
}
246285
247286
.log-viewer {

spring-boot-admin-server-ui/src/main/frontend/views/instances/shell/sba-instance-section.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div
66
:class="
77
classNames({
8+
'sba-instance-section-content': true,
89
'flex-1': true,
910
flex: layoutOptions.isFlex,
1011
'px-2 md:px-6 py-6': !layoutOptions.noMargin,

0 commit comments

Comments
 (0)