Skip to content

Commit be2b3db

Browse files
authored
fix: cannot x-scroll with shortcut (#18656)
1 parent a2a76d9 commit be2b3db

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/VirtualDataTable.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
<script lang="ts" setup>
213213
import { useWindowSize, watchDebounced } from "@vueuse/core";
214214
import { NPerformantEllipsis, NVirtualList } from "naive-ui";
215-
import { nextTick, ref } from "vue";
215+
import { nextTick, onMounted, onUnmounted, ref } from "vue";
216216
import { type ComposedDatabase, DEBOUNCE_SEARCH_DELAY } from "@/types";
217217
import type { MaskingReason } from "@/types/proto-es/v1/sql_service_pb";
218218
import { type QueryRow } from "@/types/proto-es/v1/sql_service_pb";
@@ -351,6 +351,35 @@ watchDebounced(
351351
{ debounce: DEBOUNCE_SEARCH_DELAY }
352352
);
353353
354+
// Handle shift+wheel for horizontal scrolling
355+
// Use capture phase to intercept before NVirtualList handles it
356+
const handleWheel = (event: WheelEvent) => {
357+
const container = containerRef.value;
358+
if (!container) return;
359+
360+
// Only handle shift+wheel when there's horizontal overflow
361+
const hasHorizontalOverflow = container.scrollWidth > container.clientWidth;
362+
if (!event.shiftKey || !hasHorizontalOverflow) return;
363+
364+
event.preventDefault();
365+
event.stopPropagation();
366+
container.scrollLeft += event.deltaY || event.deltaX;
367+
};
368+
369+
onMounted(() => {
370+
// Use capture phase to intercept before NVirtualList
371+
containerRef.value?.addEventListener("wheel", handleWheel, {
372+
passive: false,
373+
capture: true,
374+
});
375+
});
376+
377+
onUnmounted(() => {
378+
containerRef.value?.removeEventListener("wheel", handleWheel, {
379+
capture: true,
380+
});
381+
});
382+
354383
defineExpose({
355384
scrollTo: (index: number) =>
356385
virtualListRef.value?.scrollTo({

0 commit comments

Comments
 (0)