- Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: localized block fields #14587
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
fix: localized block fields #14587
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
| await saveDocAndAssert(page) | ||
| await changeLocale(page, 'pt') | ||
| | ||
| await changeLocale(page, spanishLocale) |
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.
The key here was to switch to a locale that used the locale previously filled out as a fallback. PT uses ES as a fallback so it looked like it worked. Switching it to ES made the issue appear.
| if (collection && id) { | ||
| entitySlug = collection.slug | ||
| url = `${serverURL}${api}/${entitySlug}/${id}?depth=0&draft=true&autosave=true&locale=${localeRef.current}` | ||
| url = `${serverURL}${api}/${entitySlug}/${id}?depth=0&draft=true&autosave=true&fallback-locale=null&locale=${localeRef.current}` |
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.
The fix was to pass fallback-locale through as query params.
| 🚀 This is included in version v3.64.0 |
Fixes #13663
Previously #13974 was merged but it didn't actually fix the issue. I updated the tests to make them fail before making the fix in this PR.
The visual issue stemmed from to autosave not passing the
fallback-locale=nullparam. So the update function would pass the default fallback locale into afterRead and data for the nullified field would come back.The data part of that issue was previously solved by adding an array to other locales if not defined. However that clutters the db with unused data. This can be fixed by including the
formatBaseSchemain the block schema which (for localized fields) setsschema.sparse = true, so the data is only added when it is saved.