Skip to content

fix: traverse localized group and tab children in locale-resolved documents - #18232

Open
guillaume-flambard wants to merge 1 commit into
payloadcms:mainfrom
guillaume-flambard:fix/traverse-fields-localized-group-resolved
Open

guillaume-flambard wants to merge 1 commit into
payloadcms:mainfrom
guillaume-flambard:fix/traverse-fields-localized-group-resolved

Conversation

@guillaume-flambard

Copy link
Copy Markdown

traverseFields walks a document against the field schema, and it assumes that document is in the database shape: a localized group or tab holds a map of locale codes to that locale's data.

A document read back with a locale (payload.find({ locale }), payload.findByID({ locale }), payload.findGlobal({ locale })) is in the resolved shape instead, where the localized group holds its own fields directly.

The localized group and tab branch iterated every key of that value as if it were a locale. The first field name was read as a locale code, the recursion was handed the field value itself, and the object guard returned, so the whole subtree was skipped and nothing reported it.

This branch now tells the two shapes apart. When a key of the value matches one of the group's own sub field names, the value is read as resolved data and traversed directly. Otherwise the existing locale map walk runs unchanged. The same file already does this kind of shape test for localized arrays and blocks with Array.isArray.

The reproduction the issue is missing:

const fields = [
  { name: 'legal', type: 'group', localized: true, fields: [{ name: 'notice', type: 'text' }] },
]

traverseFields({
  fields,
  fillEmpty: false,
  ref: { legal: { notice: 'value' } },
  callback: ({ field }) => {
    console.log(field.name)
  },
})

Before this change it logs legal only, the notice field is never visited. After it, legal and notice.

The database shape still walks exactly as before, and packages/payload/src/utilities/traverseFields.spec.ts covers both paths.

Fixes #18217

@guillaume-flambard guillaume-flambard changed the title fix(utilities): traverse localized group and tab children in locale-resolved documents fix: traverse localized group and tab children in locale-resolved documents Sep 21, 2026
@guillaume-flambard
guillaume-flambard force-pushed the fix/traverse-fields-localized-group-resolved branch from 08f709a to 8b3ada8 Compare September 22, 2026 08:51
@FinnIckler

Copy link
Copy Markdown

Is there a blocker to get this merged? Would help us a lot

@guillaume-flambard

guillaume-flambard commented Oct 2, 2026 •

Copy link
Copy Markdown
Author

@FinnIckler no blocker on my side: CI is green, the branch merges clean, and there are no open review threads. It has been open since 21 Sep and has never had a maintainer review, which is the only thing it is waiting on.

@JarrodMFlesch is anything missing here?

This branch has not been deployed

No deployments
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.

traverseFields silently skips localized group/tab children when walking locale-resolved documents

2 participants