diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts index dc7e605d8732..96c63c55d686 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts @@ -1197,7 +1197,7 @@ export function getExternalChangedDependencies( } export const isDataPath = ( - entity: DataTreeEntity, + entity: DataTreeEntity | Partial, fullPropertyPath: string, ) => { if (isWidget(entity)) { diff --git a/app/client/src/ce/workers/common/DependencyMap/utils/getEntityDependenciesByType.ts b/app/client/src/ce/workers/common/DependencyMap/utils/getEntityDependenciesByType.ts index 6e4aa697241e..bb7060eecf17 100644 --- a/app/client/src/ce/workers/common/DependencyMap/utils/getEntityDependenciesByType.ts +++ b/app/client/src/ce/workers/common/DependencyMap/utils/getEntityDependenciesByType.ts @@ -132,16 +132,6 @@ export function getJSDependencies( dependencies = { ...dependencies, [fullPropertyPath]: newDeps }; } - for (const funcName of jsActionConfig.actionNames) { - const func = jsEntity[funcName]; - - if (func) { - dependencies[`${jsObjectName}.${funcName}.data`] = [ - `${jsObjectName}.${funcName}`, - ]; - } - } - return dependencies; } export function getActionDependencies( diff --git a/app/client/src/entities/DependencyMap/DependencyMapUtils.ts b/app/client/src/entities/DependencyMap/DependencyMapUtils.ts index f71ab477df63..413815998add 100644 --- a/app/client/src/entities/DependencyMap/DependencyMapUtils.ts +++ b/app/client/src/entities/DependencyMap/DependencyMapUtils.ts @@ -5,7 +5,9 @@ import { getEntityNameAndPropertyPath, IMMEDIATE_PARENT_REGEX, isActionConfig, + isDataPath, isJSActionConfig, + isWidget, } from "ee/workers/Evaluation/evaluationUtils"; import type { ConfigTree } from "entities/DataTree/dataTreeTypes"; import { isPathDynamicTrigger } from "utils/DynamicBindingUtils"; @@ -167,10 +169,6 @@ export class DependencyMapUtils { return false; } - static isDataPath(path: string) { - return path.endsWith(".data"); - } - static detectReactiveDependencyMisuse( dependencyMap: DependencyMap, configTree: ConfigTree, @@ -213,27 +211,34 @@ export class DependencyMapUtils { ); for (const dep of transitiveDeps) { - if (this.isTriggerPath(dep, configTree)) { - hasRun = true; - runPath = dep; - } - - if (this.isDataPath(dep)) { - hasData = true; - dataPath = dep; - } - - if ( - hasRun && - hasData && - runPath.split(".")[0] === dataPath.split(".")[0] - ) { - throw Object.assign( - new Error( - `Reactive dependency misuse: '${node}' depends on both trigger path '${runPath}' and data path '${dataPath}' from the same entity. This can cause unexpected reactivity.`, - ), - { node, triggerPath: runPath, dataPath }, - ); + const { entityName: depName } = getEntityNameAndPropertyPath(dep); + const entity = configTree[depName]; + + // to show cyclic dependency errors only for Action calls and not JSObject.body or JSObject + if (entity && entity.ENTITY_TYPE) { + if (this.isTriggerPath(dep, configTree)) { + hasRun = true; + runPath = dep; + } + + // using the isDataPath function from evalUtils to calculate data paths based on entity type + if (isDataPath(entity, dep)) { + hasData = true; + dataPath = dep; + } + + if ( + hasRun && + hasData && + runPath.split(".")[0] === dataPath.split(".")[0] + ) { + throw Object.assign( + new Error( + `Reactive dependency misuse: '${node}' depends on both trigger path '${runPath}' and data path '${dataPath}' from the same entity. This can cause unexpected reactivity.`, + ), + { node, triggerPath: runPath, dataPath }, + ); + } } } } @@ -256,7 +261,15 @@ export class DependencyMapUtils { if (!entityConfig) return; - if (!isActionConfig(entityConfig) && !isJSActionConfig(entityConfig)) { + if (isWidget(entityConfig)) { + return; + } + + // to not calculate transitive dependencies for JSObject.body and JSObject + if ( + isJSActionConfig(entityConfig) && + (current.includes(".body") || !current.includes(".")) + ) { return; }