From 27ba7dec307a4c365971109cbe445a2cbba0ad69 Mon Sep 17 00:00:00 2001 From: johnsoncherian Date: Wed, 2 Jul 2025 14:18:59 +0530 Subject: [PATCH] fix: add fallback for useModuleId hook in query panel Handle case where ModuleContext is not available by wrapping useModuleId in try-catch with 'canvas' fallback --- frontend/package.json | 2 +- .../src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 57785151d3..3034d57e39 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -267,4 +267,4 @@ "jsx" ] } -} +} \ No newline at end of file diff --git a/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js b/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js index 1a41a7f19b..b5f549a354 100644 --- a/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js +++ b/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js @@ -7,7 +7,14 @@ export const useQueryPanelKeyHooks = (onChange, value, type) => { const queryPanelHeight = useStore((state) => state.queryPanel.queryPanelHeight); const runQueryOnShortcut = useStore((state) => state.queryPanel.runQueryOnShortcut); const previewQueryOnShortcut = useStore((state) => state.queryPanel.previewQueryOnShortcut); - const moduleId = useModuleId(); + + // Handle case where ModuleContext is not available + let moduleId; + try { + moduleId = useModuleId(); + } catch (error) { + moduleId = 'canvas'; // Default fallback + } const location = useLocation(); const { pathname } = location;