From 9b59d4da170a928f037cbe4518977aec1198b5f4 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 7 Aug 2024 11:49:23 +0530 Subject: [PATCH] fix: issue with opening custom widget source editor (#35463) --- .../editorComponents/CodeEditor/index.tsx | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index 11e0d00de0..c859b8e048 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -162,6 +162,7 @@ import { } from "actions/activeFieldActions"; import CodeMirrorTernService from "utils/autocomplete/CodemirrorTernService"; import { getEachEntityInformation } from "ee/utils/autocomplete/EntityDefinitions"; +import { getCurrentPageId } from "selectors/editorSelectors"; type ReduxStateProps = ReturnType; type ReduxDispatchProps = ReturnType; @@ -1771,26 +1772,33 @@ class CodeEditor extends Component { } } -const mapStateToProps = (state: AppState, props: EditorProps) => ({ - dynamicData: getDataTreeForAutocomplete(state), - datasources: state.entities.datasources, - pluginIdToPlugin: getPluginIdToPlugin(state), - recentEntities: getRecentEntityIds(state), - lintErrors: getEntityLintErrors(state, props.dataTreePath), - editorIsFocused: getIsInputFieldFocused(state, getEditorIdentifier(props)), - editorLastCursorPosition: getCodeEditorLastCursorPosition( - state, - getEditorIdentifier(props), - ), - entitiesForNavigation: getEntitiesForNavigation( - state, - props.dataTreePath?.split(".")[0], - ), - featureFlags: selectFeatureFlags(state), - datasourceTableKeys: getAllDatasourceTableKeys(state, props.dataTreePath), - installedLibraries: selectInstalledLibraries(state), - focusedProperty: getFocusablePropertyPaneField(state), -}); +const mapStateToProps = (state: AppState, props: EditorProps) => { + const currentPageId: string = getCurrentPageId(state); + let entitiesForNavigation: EntityNavigationData = {}; + if (currentPageId) { + entitiesForNavigation = getEntitiesForNavigation( + state, + props.dataTreePath?.split(".")[0], + ); + } + return { + dynamicData: getDataTreeForAutocomplete(state), + datasources: state.entities.datasources, + pluginIdToPlugin: getPluginIdToPlugin(state), + recentEntities: getRecentEntityIds(state), + lintErrors: getEntityLintErrors(state, props.dataTreePath), + editorIsFocused: getIsInputFieldFocused(state, getEditorIdentifier(props)), + editorLastCursorPosition: getCodeEditorLastCursorPosition( + state, + getEditorIdentifier(props), + ), + entitiesForNavigation, + featureFlags: selectFeatureFlags(state), + datasourceTableKeys: getAllDatasourceTableKeys(state, props.dataTreePath), + installedLibraries: selectInstalledLibraries(state), + focusedProperty: getFocusablePropertyPaneField(state), + }; +}; // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any