diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index f6425916bb96..a75d6ef2ce58 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -381,24 +381,31 @@ class CodeEditor extends Component { const entityInformation: FieldEntityInformation = { expectedType: expected?.autocompleteDataType, }; + if (dataTreePath) { const { entityName, propertyPath } = getEntityNameAndPropertyPath( dataTreePath, ); entityInformation.entityName = entityName; const entity = dynamicData[entityName]; - if (entity && "ENTITY_TYPE" in entity) { - const entityType = entity.ENTITY_TYPE; - if ( - entityType === ENTITY_TYPE.WIDGET || - entityType === ENTITY_TYPE.ACTION - ) { - entityInformation.entityType = entityType; + + if (entity) { + if ("ENTITY_TYPE" in entity) { + const entityType = entity.ENTITY_TYPE; + if ( + entityType === ENTITY_TYPE.WIDGET || + entityType === ENTITY_TYPE.ACTION + ) { + entityInformation.entityType = entityType; + } } + + if (isActionEntity(entity)) + entityInformation.entityId = entity.actionId; + if (isWidgetEntity(entity)) + entityInformation.entityId = entity.widgetId; + entityInformation.propertyPath = propertyPath; } - if (isActionEntity(entity)) entityInformation.entityId = entity.actionId; - if (isWidgetEntity(entity)) entityInformation.entityId = entity.widgetId; - entityInformation.propertyPath = propertyPath; } return entityInformation; };