diff --git a/frontend/src/Editor/CodeEditor/utils.js b/frontend/src/Editor/CodeEditor/utils.js index b5a7b7f999..6bf6dbd7ca 100644 --- a/frontend/src/Editor/CodeEditor/utils.js +++ b/frontend/src/Editor/CodeEditor/utils.js @@ -183,6 +183,8 @@ function getDynamicVariables(text) { const resolveMultiDynamicReferences = (code, lookupTable) => { let resolvedValue = code; + const isComponentValue = code.includes('components.') || false; + const allDynamicVariables = getDynamicVariables(code); if (allDynamicVariables) { @@ -191,13 +193,14 @@ const resolveMultiDynamicReferences = (code, lookupTable) => { const { toResolveReference } = inferJSExpAndReferences(variableToResolve, lookupTable.hints); - if (toResolveReference && lookupTable.hints.has(toResolveReference)) { + if (!isComponentValue && toResolveReference && lookupTable.hints.has(toResolveReference)) { const idToLookUp = lookupTable.hints.get(variableToResolve); const res = lookupTable.resolvedRefs.get(idToLookUp); resolvedValue = resolvedValue.replace(variable, res); } else { - const [resolvedCode] = resolveCode(variableToResolve, lookupTable, {}, true, [], true); + const currentState = useCurrentStateStore.getState(); + const [resolvedCode] = resolveCode(variableToResolve, currentState, {}, true, [], true); resolvedValue = resolvedCode; } @@ -242,8 +245,8 @@ export const resolveReferences = (query, validationSchema, customResolvers = {}, } const { toResolveReference, jsExpression, jsExpMatch } = inferJSExpAndReferences(value, lookupTable.hints); - - if (!jsExpMatch && toResolveReference && lookupTable.hints.has(toResolveReference)) { + const isComponentValue = toResolveReference?.startsWith('components.') || false; //!Notes: As we removed the updating of references on currentState changes, exposed variable of components are dynamic and cannot be controlled in any form, so we are resolving only components references with our legacy approach. + if (!isComponentValue && !jsExpMatch && toResolveReference && lookupTable.hints.has(toResolveReference)) { const idToLookUp = lookupTable.hints.get(toResolveReference); resolvedValue = lookupTable.resolvedRefs.get(idToLookUp); diff --git a/frontend/src/_stores/dataQueriesStore.js b/frontend/src/_stores/dataQueriesStore.js index d905cee09a..cc4f602b78 100644 --- a/frontend/src/_stores/dataQueriesStore.js +++ b/frontend/src/_stores/dataQueriesStore.js @@ -101,6 +101,7 @@ export const useDataQueriesStore = create( set({ dataQueries }); if (type === 'mappingUpdate') { const { actions } = useQueryPanelStore.getState(); + actions.setSelectedQuery(null); const queryId = dataQueries[0]?.id; actions.setSelectedQuery(queryId);