-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(dashboard): Initialize complete price structure for variants in price list edit #14273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…currency and region prices
🦋 Changeset detectedLatest commit: d066d6f The changes in this PR will be included in the next version bump. This PR includes changesets to release 75 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@docloulou is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
|
@adrien2p @carlos-r-l-rodrigues Hi, is there any chance of including this in the next release? Thanks! |
adrien2p
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! @olivermrbl any objections to that, that I might have missed?
fPolic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
What — What changes are introduced in this PR?
Initialize empty currency_prices and region_prices objects for all product variants in the price list edit form, regardless of whether they have existing prices.
Why — Why are these changes relevant or necessary?
When editing a price list with many products/variants, the DataGrid uses virtualization to only render visible rows. The form uses Controller from react-hook-form which only registers fields when the component is rendered.
Previously, variants without existing prices were initialized with an empty object {} instead of the expected structure { currency_prices: {}, region_prices: {} }. This caused Zod validation to fail on unrendered (virtualized) rows because the schema requires both currency_prices and region_prices properties to exist.
As a result, users had to scroll through the entire DataGrid to render all cells before being able to submit the form.
How — How have these changes been implemented?
Modified the initRecord function in price-list-prices-edit-form.tsx to always initialize variants with the complete structure containing empty currency_prices and region_prices objects, matching the pattern already used in the price list add form.
Testing — How have these changes been tested, or how can the reviewer test the feature?
Examples
Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.
This helps with documentation and ensures maintainers can quickly understand and verify the change.
// Example usageChecklist
Please ensure the following before requesting a review:
[ ] I have added a changeset for this PR
Every non-breaking change should be marked as a patch
To add a changeset, run yarn changeset and follow the prompts
[ ] The changes are covered by relevant tests
[x] I have verified the code works as intended locally
[ ] I have linked the related issue(s) if applicable
Additional Context
This fix aligns the price list edit form with the existing implementation in the price list add form (price-list-prices-add-prices-form.tsx), which already initializes variants with the complete structure.
before :
before.mp4
after :
after.mp4
Note
Always initialize each variant with
{ currency_prices: {}, region_prices: {} }in the price list edit form to ensure schema-compliant defaults.price-list-prices-edit-form.tsx):initRecordis initialized with{ currency_prices: {}, region_prices: {} }.{}variant entries by defaulting missingcurrency_pricesandregion_pricesto empty objects.Written by Cursor Bugbot for commit 85fba66. This will update automatically on new commits. Configure here.