diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index d03aeafcaa..557fd1165f 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -111,6 +111,7 @@ import { isExecuteSqlInNewResultTabShortcut, isExecuteSqlShortcut, isFocusSearchShortcut, + isFocusWhereShortcut, isGoToColumnShortcut, isModRShortcut, handleTabHistoryNavigationShortcut, @@ -3708,6 +3709,14 @@ async function handleKeydown(e: KeyboardEvent) { const shortcuts = settingsStore.editorSettings.shortcuts; if (showTabSwitcher.value) return; + if (isFocusWhereShortcut(e, shortcuts) && !showSettingsPage.value && !showPluginCenter.value && !showDriverStore.value) { + const target = e.target instanceof Element ? e.target : null; + if (!target?.closest('[role="dialog"], [role="alertdialog"]') && contentAreaRef.value?.focusWhere()) { + e.preventDefault(); + e.stopPropagation(); + return; + } + } // Grid-scoped shortcuts normally win inside DataGrid. Keep that precedence // for a data tab even when focus is in a sibling input, where the grid's // local listener intentionally leaves native editing untouched. diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 83b309be97..8f86947aeb 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -202,6 +202,7 @@ import { isDeleteCurrentRowShortcut, isEditTableStructureShortcut, isFocusSearchShortcut, + isFocusWhereShortcut, isGoToColumnShortcut, isGoToFirstPageShortcut, isGoToLastPageShortcut, @@ -1071,6 +1072,7 @@ const transposeScrollRef = ref(); const transposeScrollLeft = ref(0); const transposeViewportWidth = ref(0); const { sortColumn: sortCol, sortColumnIndex: sortColIndex, sortDirection: sortDir, sortMode, setSort, clearSort } = useDataGridSort(); +const queryControlsRef = ref>(); const searchBarRef = ref<{ focus: (select?: boolean) => void } | null>(null); const replaceOpen = ref(false); const replacementText = ref(""); @@ -1889,6 +1891,11 @@ function navigateSuggestion(delta: number) { dataGridSearch.navigateSuggestion(delta); } +function focusWhere(): boolean { + if (!canUseWhereSearch.value) return false; + return queryControlsRef.value?.focusWhere() ?? false; +} + function focusSearch(target: Element | null = null): boolean { const tableInfoDrawer = target?.closest("[data-table-info-drawer]"); if (tableInfoDrawer) { @@ -9464,6 +9471,12 @@ function openCellDetailSearch(): boolean { async function onGridKeydown(event: KeyboardEvent) { if (event.defaultPrevented) return; + if (isFocusWhereShortcut(event, settingsStore.editorSettings.shortcuts) && focusWhere()) { + event.preventDefault(); + event.stopPropagation(); + return; + } + const targetAllowsNativeClipboard = eventTargetAllowsNativeClipboard(event); if (!targetAllowsNativeClipboard && props.context === "table-data" && canOpenTableStructureEditor.value && isEditTableStructureShortcut(event, settingsStore.editorSettings.shortcuts)) { event.preventDefault(); @@ -11924,6 +11937,7 @@ defineExpose({ setMultiRowTranspose, toggleMultiRowTranspose, focusSearch, + focusWhere, openGoToColumn, visibleColumnCount, displayableColumnCount, @@ -12425,6 +12439,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val