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
This commit is contained in:
johnsoncherian 2025-07-02 14:18:59 +05:30 committed by Kavin Venkatachalam
parent 108aa42eea
commit 27ba7dec30
2 changed files with 9 additions and 2 deletions

View file

@ -267,4 +267,4 @@
"jsx"
]
}
}
}

View file

@ -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;