diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js
index 0d41931a55..9f253f9f75 100644
--- a/packages/builder/src/builderStore/dataBinding.js
+++ b/packages/builder/src/builderStore/dataBinding.js
@@ -199,15 +199,7 @@ export const getContextProviderComponents = (
return []
}
- // Get the component tree leading up to this component, ignoring the component
- // itself
- const path = findComponentPath(asset.props, componentId)
- if (!options?.includeSelf) {
- path.pop()
- }
-
- // Filter by only data provider components
- return path.filter(component => {
+ return findAllMatchingComponents(asset.props, component => {
const def = store.actions.components.getDefinition(component._component)
if (!def?.context) {
return false
@@ -222,6 +214,30 @@ export const getContextProviderComponents = (
const contexts = Array.isArray(def.context) ? def.context : [def.context]
return contexts.find(context => context.type === type) != null
})
+ //
+ // // Get the component tree leading up to this component, ignoring the component
+ // // itself
+ // const path = findComponentPath(asset.props, componentId)
+ // if (!options?.includeSelf) {
+ // path.pop()
+ // }
+ //
+ // // Filter by only data provider components
+ // return path.filter(component => {
+ // const def = store.actions.components.getDefinition(component._component)
+ // if (!def?.context) {
+ // return false
+ // }
+ //
+ // // If no type specified, return anything that exposes context
+ // if (!type) {
+ // return true
+ // }
+ //
+ // // Otherwise only match components with the specific context type
+ // const contexts = Array.isArray(def.context) ? def.context : [def.context]
+ // return contexts.find(context => context.type === type) != null
+ // })
}
/**
diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js
index e264dc099b..fb3eb8f1d9 100644
--- a/packages/builder/src/builderStore/store/frontend.js
+++ b/packages/builder/src/builderStore/store/frontend.js
@@ -621,10 +621,9 @@ export const getFrontendStore = () => {
else {
if (setting.type === "dataProvider") {
// Validate data provider exists, or else clear it
- const treeId = parent?._id || component._id
- const path = findComponentPath(screen?.props, treeId)
- const providers = path.filter(component =>
- component._component?.endsWith("/dataprovider")
+ const providers = findAllMatchingComponents(
+ screen?.props,
+ component => component._component?.endsWith("/dataprovider")
)
// Validate non-empty values
const valid = providers?.some(dp => value.includes?.(dp._id))
diff --git a/packages/builder/src/components/design/settings/controls/DataProviderSelect.svelte b/packages/builder/src/components/design/settings/controls/DataProviderSelect.svelte
index 83255ec325..9fd220e798 100644
--- a/packages/builder/src/components/design/settings/controls/DataProviderSelect.svelte
+++ b/packages/builder/src/components/design/settings/controls/DataProviderSelect.svelte
@@ -1,15 +1,16 @@