fix(sidebar): focus object search after opening a database

This commit is contained in:
zipg authored and GitHub committed 2026-09-17 14:32:19 +08:00
1 parent 8567e50887
commit 90ad4e62e6
6 files changed
+117 -10

No files matched your search

+16
View File
@@ -53,6 +53,7 @@ import { translateBackendError } from "@/i18n/backend-errors";
import * as api from "@/lib/backend/api";
import { connectionRedactedNameLabel } from "@/lib/connection/connectionPresentation";
import { quickConnectionOpenTarget } from "@/lib/connection/connectionOpenTarget";
import { OBJECT_BROWSER_SEARCH_FOCUS_EVENT, objectBrowserSearchFocusTabId } from "@/lib/tabs/objectBrowserSearchFocus";
import { parseRecentConnectionIds, rankRecentConnections, RECENT_CONNECTION_IDS_STORAGE_KEY, recordRecentConnection } from "@/lib/connection/recentConnections";
import { resolveDefaultDatabase } from "@/lib/database/defaultDatabase";
import { normalizeSqliteNamespace } from "@/lib/database/sqliteNamespace";
@@ -1068,6 +1069,19 @@ function activateQuerySurface() {
activateMainContentSurface("query");
}
async function focusRequestedObjectBrowserSearch(event: Event) {
const tabId = objectBrowserSearchFocusTabId(event);
if (!tabId) return;
await nextTick();
let remainingFrames = 8;
const focusWhenReady = () => {
if (queryStore.activeTabId !== tabId || contentAreaRef.value?.focusSearch()) return;
remainingFrames -= 1;
if (remainingFrames > 0) window.requestAnimationFrame(focusWhenReady);
};
focusWhenReady();
}
function activateOpenSpecialPageFallback() {
if (settingsPageTabOpen.value) {
activateMainContentSurface("settings");
@@ -3625,6 +3639,7 @@ onMounted(async () => {
document.addEventListener("visibilitychange", handleTabSwitcherVisibilityChange);
window.addEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
window.addEventListener("dbx:activate-query-surface", activateQuerySurface);
window.addEventListener(OBJECT_BROWSER_SEARCH_FOCUS_EVENT, focusRequestedObjectBrowserSearch);
window.addEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);
window.addEventListener("dbx:ai-run-notify", handleAiRunNotify);
if (isDesktop) {
@@ -3708,6 +3723,7 @@ onUnmounted(() => {
tabSwitcherKeyboard.reset();
window.removeEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
window.removeEventListener("dbx:activate-query-surface", activateQuerySurface);
window.removeEventListener(OBJECT_BROWSER_SEARCH_FOCUS_EVENT, focusRequestedObjectBrowserSearch);
window.removeEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);
window.removeEventListener("dbx:ai-run-notify", handleAiRunNotify);
document.removeEventListener("contextmenu", handleContextMenu);