From a8ac0bba3a53f207d202ccfc10ae6b7c11620374 Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Tue, 9 Jul 2024 15:01:59 +0200 Subject: [PATCH 1/3] scroll to line numbers and nearest --- report-viewer/src/components/fileDisplaying/CodeLine.vue | 8 -------- report-viewer/src/components/fileDisplaying/CodePanel.vue | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/report-viewer/src/components/fileDisplaying/CodeLine.vue b/report-viewer/src/components/fileDisplaying/CodeLine.vue index bcced0c92b..e0644f65d4 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 75010c1eac..4018523d36 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' }) }) } From 666f417e5805fbb774b458cf4a372759f610d8d2 Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Tue, 16 Jul 2024 16:23:56 +0200 Subject: [PATCH 2/3] scroll to center --- .../src/components/ScrollableComponent.vue | 19 ++++++++++++- .../components/fileDisplaying/CodePanel.vue | 27 +++++++++---------- .../fileDisplaying/FilesContainer.vue | 19 ++++++++++--- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/report-viewer/src/components/ScrollableComponent.vue b/report-viewer/src/components/ScrollableComponent.vue index 9866809577..2e5a0e7fdd 100644 --- a/report-viewer/src/components/ScrollableComponent.vue +++ b/report-viewer/src/components/ScrollableComponent.vue @@ -2,9 +2,26 @@ Offers a unstyled scrollable container --> + + diff --git a/report-viewer/src/components/fileDisplaying/CodePanel.vue b/report-viewer/src/components/fileDisplaying/CodePanel.vue index 4018523d36..6dce9e8e3c 100644 --- a/report-viewer/src/components/fileDisplaying/CodePanel.vue +++ b/report-viewer/src/components/fileDisplaying/CodePanel.vue @@ -58,7 +58,7 @@