fix(sidebar): focus object search after opening a database
This commit is contained in:
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;
|
||||
}
|
||||
Reference in new issue
Block a user