diff --git a/packages/client/src/components/Provider.svelte b/packages/client/src/components/Provider.svelte index bc95412bab..3c894f6723 100644 --- a/packages/client/src/components/Provider.svelte +++ b/packages/client/src/components/Provider.svelte @@ -11,16 +11,21 @@ // Clone and create new data context for this component tree const context = getContext("context") const component = getContext("component") - const newContext = createContextStore($context) + const newContext = createContextStore() setContext("context", newContext) + + let initiated = false $: providerKey = key || $component.id + // Add data context + $: { + newContext.actions.provideData(providerKey, $context, data) + initiated = true + } + // Instance ID is unique to each instance of a provider let instanceId - // Add data context - $: data !== undefined && newContext.actions.provideData(providerKey, data) - // Add actions context $: { if (instanceId) { @@ -51,4 +56,6 @@ }) - +{#if initiated} + +{/if} diff --git a/packages/client/src/store/context.js b/packages/client/src/store/context.js index 80777cbeff..5725f94231 100644 --- a/packages/client/src/store/context.js +++ b/packages/client/src/store/context.js @@ -1,22 +1,20 @@ import { writable } from "svelte/store" -export const createContextStore = existingContext => { - const store = writable({ ...existingContext }) +export const createContextStore = () => { + const store = writable({}) // Adds a data context layer to the tree - const provideData = (providerId, data) => { - if (!providerId) { - return - } - store.update(state => { - state[providerId] = data + const provideData = (providerId, context, data) => { + let newData = { ...context } + if (providerId && data !== undefined) { + newData[providerId] = data // Keep track of the closest component ID so we can later hydrate a "data" prop. // This is only required for legacy bindings that used "data" rather than a // component ID. - state.closestComponentId = providerId - return state - }) + newData.closestComponentId = providerId + } + store.set(newData) } // Adds an action context layer to the tree @@ -32,7 +30,6 @@ export const createContextStore = existingContext => { return { subscribe: store.subscribe, - update: store.update, actions: { provideData, provideAction }, } } diff --git a/packages/standard-components/src/RowDetail.svelte b/packages/standard-components/src/RowDetail.svelte index ed46fd6927..8a413dfb43 100644 --- a/packages/standard-components/src/RowDetail.svelte +++ b/packages/standard-components/src/RowDetail.svelte @@ -1,46 +1,57 @@ {#if row} -
- + +
- -
+
+ {/if}