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

@@ -0,0 +1,16 @@
export const OBJECT_BROWSER_SEARCH_FOCUS_EVENT = "dbx:focus-object-browser-search";
type ObjectBrowserSearchFocusDetail = {
tabId: string;
};
export function requestObjectBrowserSearchFocus(tabId: string) {
if (typeof window === "undefined") return;
window.dispatchEvent(new CustomEvent<ObjectBrowserSearchFocusDetail>(OBJECT_BROWSER_SEARCH_FOCUS_EVENT, { detail: { tabId } }));
}
export function objectBrowserSearchFocusTabId(event: Event): string | undefined {
if (!(event instanceof CustomEvent)) return undefined;
const tabId = (event.detail as Partial<ObjectBrowserSearchFocusDetail> | null)?.tabId;
return typeof tabId === "string" && tabId.length > 0 ? tabId : undefined;
}