Skip to content

fix(ui): cache client schema maps per language - #18585

Merged
nathanlentz merged 1 commit into
payloadcms:mainfrom
kaanisthatyou:fix/client-schema-map-language
Oct 7, 2026
Merged

nathanlentz merged 1 commit into
payloadcms:mainfrom
kaanisthatyou:fix/client-schema-map-language

Conversation

@kaanisthatyou

Copy link
Copy Markdown
Contributor

What?

Cache the client field schema map per admin language.

Why?

getClientSchemaMap keyed its process-wide cache by entity slug only. The map is built from the per-language client config and runs label functions with the request's i18n, so whichever language filled the cache first was served to everyone. That is why richText fields and fields with a custom Field component (rendered through form state) showed labels in another language (#18583).

While testing this I found a second piece: buildClientFieldSchemaMap sets the translated password/confirm-password labels on a module-level baseAuthFields array and puts those same objects into the map. With per-language maps, building the French map would rename the password fields in the cached English one.

How?

  • Add i18n.language to the cache key, the same way getClientConfig caches per language.
  • Build the auth fields as new objects on each call instead of mutating the shared ones.

New getClientSchemaMap.spec.ts: both tests fail on main, and the auth test still fails with only the cache key change. packages/ui/src/utilities unit specs pass (149).

#18168 changes the same cache key for auth state; whichever lands second needs a one-line rebase. The same cache key exists on 3.x.

Fixes #18583

The client schema map was cached per entity slug only, so labels came out
in the language of the first request that filled the cache. Add the
language to the cache key, and build the auth fields per call so a map for
one language does not rename the password fields of another.

Fixes payloadcms#18583

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@nathanlentz nathanlentz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and this happens to fix an issue I just ran into from CI in another body of work. I think this bug technically exists server side but that doesn't block this from going through in my opinion.

Thanks for the contribution!

@nathanlentz
nathanlentz merged commit 629fbae into payloadcms:main Oct 7, 2026
292 checks passed
@VeiaG

VeiaG commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

@nathanlentz should #18583 be reopened, as this issue opened with v3 tag ? Or there is no plans to release this fix to v3 (v4 soon confirmed 😁 ) ?

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 This is included in version v4.0.0-canary.38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field labels on richText and custom-component fields are cached in the first admin language rendered

3 participants