3838 <LogTableRow v-for =" (row, rowNumber) in renderedItems"
3939 :key =" rowNumber"
4040 :row =" row"
41+ class =" log-table__row"
4142 @show-details =" showDetailsForRow" />
4243 </tbody >
4344 <tfoot role =" rowgroup" class =" log-table__footer" >
@@ -74,10 +75,6 @@ import LogSearch from '../LogSearch.vue'
7475
7576// Items to render before and after the visible area
7677const bufferItems = 3
77- // Fixed height of LogTableRow
78- const itemHeight = 42
79- // Fixed height of LogTableHeader
80- const theadHeight = 44
8178
8279const settingsStore = useSettingsStore ()
8380const logStore = useLogStore ()
@@ -165,8 +162,10 @@ const resizeObserver = ref<ResizeObserver | null>(null)
165162const firstVisibleRowIndex = ref (0 )
166163const startIndex = computed (() => Math .max (0 , firstVisibleRowIndex .value - bufferItems ))
167164
168- const tableHeight = ref (0 )
169- const itemsInViewport = computed (() => Math .ceil ((tableHeight .value - theadHeight ) / itemHeight ) + bufferItems * 2 )
165+ const tableRootHeight = ref (0 )
166+ const tableHeadHeight = ref (44 )
167+ const tableRowHeight = ref (42 )
168+ const itemsInViewport = computed (() => Math .ceil ((tableRootHeight .value - tableHeadHeight .value ) / tableRowHeight .value ) + bufferItems * 2 )
170169
171170const renderedItems = computed (() => sortedRows .value .slice (startIndex .value , startIndex .value + itemsInViewport .value ))
172171
@@ -176,14 +175,16 @@ const tbodyStyle = computed(() => {
176175 const hiddenAfterItems = Math .min (sortedRows .value .length - startIndex .value , lastIndex )
177176
178177 return {
179- paddingTop: ` ${startIndex .value * itemHeight }px ` ,
180- paddingBottom: isOverScrolled ? 0 : ` ${hiddenAfterItems * itemHeight }px ` ,
178+ paddingTop: ` ${startIndex .value * tableRowHeight . value }px ` ,
179+ paddingBottom: isOverScrolled ? 0 : ` ${hiddenAfterItems * tableRowHeight . value }px ` ,
181180 }
182181})
183182
184183onMounted (() => {
185184 resizeObserver .value = new ResizeObserver (debounce (() => {
186- tableHeight .value = tableRoot .value ?.clientHeight ?? 0
185+ tableRootHeight .value = tableRoot .value ?.clientHeight ?? 0
186+ tableHeadHeight .value = tableRoot .value ?.querySelector (' thead.log-table__header' )?.clientHeight ?? 44
187+ tableRowHeight .value = tableRoot .value ?.querySelector (' tr.log-table__row:not(.expanded)' )?.clientHeight ?? 42
187188 logger .debug (' VirtualList resizeObserver updated' )
188189 onScroll ()
189190 }, 100 ))
@@ -200,7 +201,7 @@ onBeforeUnmount(() => {
200201
201202function onScroll() {
202203 // Max 0 to prevent negative index
203- firstVisibleRowIndex .value = Math .max (0 , Math .round (tableRoot .value ! .scrollTop / itemHeight ))
204+ firstVisibleRowIndex .value = Math .max (0 , Math .round (tableRoot .value ! .scrollTop / tableRowHeight . value ))
204205}
205206 </script >
206207
@@ -294,5 +295,8 @@ function onScroll() {
294295 }
295296 }
296297
298+ & __row {
299+ min-height : 42px ;
300+ }
297301}
298302 </style >
0 commit comments