puck
puck copied to clipboard
Add parent data to resolve data params
Closes #1359.
This PR adds parent data to resolveData, matching the behavior of resolveFields as required in #1359.
Changes made
- The
resolveDataconfig type now includes aparent.- The app store
resolveComponentDatawas updated to retrieve the parent data from state and pass it to the libresolveComponentDatafunction. - The lib
resolveComponentDatawas updated to receive the parent data from its caller and pass it to the config-defined function. - The lib
resolveAllDatawas updated to pass parent data on each recursive call to the config-defined function.resolveAllDatanow fully iterates top to bottom. Previously, this was done for slots but not for zones, which made efficient parent resolution difficult. A new utility,groupZonesByComponent, was introduced to handle this.resolveAllDatawas also updated to fix a bug where unresolvedzonespromises were returned in the data.resolveAllDatanow triggers all childresolveDatacalls in parallel, for both zones and slots.
- The app store
- The
resolveDataconfig type now includes amovedtrigger, and the store'sresolveComponentDatanow runs when components are moved between slots or dropzones.- The
resolveComponentDatacache now stores the parent ID for each execution and re-executes when it changes (formovedtriggers). - A new hook,
useResolveDataOnMoved, was added to track component drops and triggerresolveComponentDatawith amovedtrigger. The cache ensures it only runs if the parent ID changed.
- The
- Added documentation for the new
parentparam,movedtrigger, and updated execution flow. - Added tests for all new behavior.
Manual tests
- Confirmed that
resolveDataruns the same number of times on editor load, insertion, deletion, replacement, and reordering within the same slot, using sample data and config. - Confirmed that
resolveDataruns once per component when a component is reordered across slots (i.e. its parent changes). - Confirmed that conditional data resolution based on the parent works as expected:
resolveData: (data, params) => {
if (params.parent.type === "Grid") {
return { props: { title: "Hello from Grid child" } };
}
return data;
}
https://github.com/user-attachments/assets/f1d9eaca-4a71-4f42-ab2c-a4a23075b281
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| puck-demo | Preview | Comment | Nov 11, 2025 3:55am | |
| puck-docs | Preview | Comment | Nov 11, 2025 3:55am |
Applied the requested changes, only need to go through the commit history to fix it up with you!