From aca4457a328333e8f0d80c2c32f6370445937104 Mon Sep 17 00:00:00 2001 From: ashit-rath <88306433+ashit-rath@users.noreply.github.com> Date: Wed, 25 Aug 2021 19:41:15 +0530 Subject: [PATCH] Fix: RTE crash on defaultText change (#6789) --- .../editorComponents/CodeEditor/index.tsx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index f6425916bb..a75d6ef2ce 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; };