From 15b86ad6c9d5ffe1ace59922a861b91743e3773c Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 7 Jul 2026 01:49:41 +0800 Subject: [PATCH] fix(grid): highlight and locate Ctrl+F matches in transpose view --- apps/desktop/src/components/grid/DataGrid.vue | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 9f7ec797aa..97203fad38 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -4125,6 +4125,20 @@ function cellIsCurrentMatch(displayRow: number, col: number): boolean { return m.kind === "cell" && m.displayRow === displayRow && m.col === col; } +// Transpose view renders fields as rows; a column-name match (displayRow = -1) +// maps to the field row header at the field's column index. +function transposeHeaderIsSearchMatch(fieldIndex: number): boolean { + if (isScrolling.value) return false; + return searchMatchSet.value.has(`column:-1:${fieldIndex}`); +} + +function transposeHeaderIsCurrentMatch(fieldIndex: number): boolean { + if (isScrolling.value) return false; + const m = currentSearchMatch.value; + if (!m) return false; + return m.kind === "column" && m.col === fieldIndex; +} + function navigateMatch(delta: number) { const total = searchMatches.value.length; if (total === 0) return; @@ -4136,6 +4150,10 @@ function scrollToCurrentMatch() { const idx = currentMatchIndex.value; if (idx < 0 || idx >= searchMatches.value.length) return; const match = searchMatches.value[idx]; + if (showTranspose.value) { + scrollTransposeMatchIntoView(match); + return; + } const visibleColIdx = visibleColumnIndexes.value.indexOf(match.col); if (visibleColIdx >= 0) scrollGridColumnIntoView(visibleColIdx); if (match.kind === "column") { @@ -4162,6 +4180,27 @@ function scrollToCurrentMatch() { if (rowEl) rowEl.scrollIntoView({ block: "center" }); } +// In transpose view records are columns (horizontal) and fields are rows +// (vertical). Bring the matched record column into the horizontal viewport and +// the matched field row into the vertical viewport. +function scrollTransposeMatchIntoView(match: SearchMatch) { + nextTick(() => { + const scroller = transposeScrollRef.value; + // Both match kinds use `col` as the field (transpose row) index: cell + // matches store the field/value index, column-name matches store the field. + const fieldIndex = match.col; + if (scroller && !(scroller instanceof HTMLElement)) { + // RecycleScroller component instance exposes scrollToItem via vue-virtual-scroller. + (scroller as { scrollToItem?: (index: number) => void }).scrollToItem?.(fieldIndex); + } else if (scroller instanceof HTMLElement) { + scroller.scrollTop = fieldIndex * 30; + } + if (match.kind === "cell") { + scrollTransposeRecordIntoView(match.displayRow); + } + }); +} + function getRowItem(rowId: number): RowItem | undefined { const rowIndex = displayRowIndexById(rowId); return rowIndex >= 0 ? displayItemAt(rowIndex) : undefined; @@ -8774,9 +8813,17 @@ const gridContextMenuItems = computed(() => {
-