diff --git a/report-viewer/src/components/fileDisplaying/CodeLine.vue b/report-viewer/src/components/fileDisplaying/CodeLine.vue index bcced0c92..e0644f65d 100644 --- a/report-viewer/src/components/fileDisplaying/CodeLine.vue +++ b/report-viewer/src/components/fileDisplaying/CodeLine.vue @@ -57,14 +57,6 @@ function matchSelected(match?: MatchInSingleFile) { const lineRef = ref(null) -function scrollTo() { - if (lineRef.value) { - lineRef.value.scrollIntoView({ block: 'center' }) - } -} - -defineExpose({ scrollTo }) - interface TextPart { line: string match?: MatchInSingleFile diff --git a/report-viewer/src/components/fileDisplaying/CodePanel.vue b/report-viewer/src/components/fileDisplaying/CodePanel.vue index 75010c1ea..4018523d3 100644 --- a/report-viewer/src/components/fileDisplaying/CodePanel.vue +++ b/report-viewer/src/components/fileDisplaying/CodePanel.vue @@ -30,6 +30,7 @@ v-for="(_, index) in codeLines" :key="index" class="col-span-1 col-start-1 row-span-1 text-right" + ref="lineRefs" :style="{ gridRowStart: index + 1 }" @@ -40,7 +41,6 @@ ([]) +const lineRefs = ref([]) const codeLines: Ref<{ line: string; matches: MatchInSingleFile[] }[]> = computed(() => highlight(props.file.data, props.highlightLanguage).map((line, index) => { @@ -116,7 +116,7 @@ function matchSelected(match: Match) { function scrollTo(lineNumber: number) { collapsed.value = false nextTick(function () { - lineRefs.value[lineNumber - 1].scrollTo() + lineRefs.value[lineNumber - 1].scrollIntoView({ block: 'nearest' }) }) }