From c45be81af50ee749432a2fcf8d8c03eeb5440085 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 27 Jan 2026 21:45:44 -0300 Subject: [PATCH] refactor: lazy load KBar data fetching hooks only when opened (#27314) * refactor: lazy load KBar data fetching hooks only when opened Co-Authored-By: alex@cal.com * refactor: move KBar data fetching into RenderResults for proper lazy loading Co-Authored-By: alex@cal.com --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- apps/web/modules/shell/Kbar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/modules/shell/Kbar.tsx b/apps/web/modules/shell/Kbar.tsx index 838ec8f578..d8e861bd9f 100644 --- a/apps/web/modules/shell/Kbar.tsx +++ b/apps/web/modules/shell/Kbar.tsx @@ -1,4 +1,5 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData"; +import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { isMac } from "@calcom/lib/isMac"; import { trpc } from "@calcom/trpc/react"; @@ -20,8 +21,6 @@ import { useRouter } from "next/navigation"; import type { ReactNode } from "react"; import { useEffect, useMemo } from "react"; -import dayjs from "@calcom/dayjs"; - type ShortcutArrayType = { shortcuts?: string[]; }; @@ -319,8 +318,6 @@ function CommandKey(): JSX.Element { const KBarContent = (): JSX.Element => { const { t } = useLocale(); - useEventTypesAction(); - useUpcomingBookingsAction(); return ( @@ -459,6 +456,9 @@ function RenderResults(): JSX.Element { const { searchQuery } = useKBar((state) => ({ searchQuery: state.searchQuery })); const { t } = useLocale(); + useEventTypesAction(); + useUpcomingBookingsAction(); + if (results.length === 0 && searchQuery.trim().length > 0) { return ; }