feat: support slug fields nested within groups, arrays and blocks - #17799
Open
bastienrobert wants to merge 1 commit into
Open
feat: support slug fields nested within groups, arrays and blocks#17799bastienrobert wants to merge 1 commit into
bastienrobert wants to merge 1 commit into
Conversation
bastienrobert
requested review from
AlessioGr,
JarrodMFlesch,
denolfe and
jacobsfletch
as code owners
August 14, 2026 18:09
bastienrobert
marked this pull request as draft
August 14, 2026 18:14
bastienrobert
force-pushed
the
feat/slug-field-sibling-data
branch
from
August 14, 2026 18:43
e54d614 to
b5029d4
Compare
bastienrobert
marked this pull request as ready for review
August 14, 2026 18:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which branch should this PR target?
main— Payload v4 development. New features, enhancements, and v4 bug fixes go here.What?
The slug field only generates correctly at the top level of a document.
useAsSlugis documented as naming a sibling field, but the hook reads the document root, so a slug nested in a group, array row or block derives from the wrong level or from nothing.How?
useAsSlugnow resolves against the slug field's siblings, and the stored value is read frompreviousSiblingDocinstead oforiginalDoc. At the top levelsiblingDataanddataare the same object, so nothing changes for existing configs.eg.
Each row generates its own slug from its own heading, both on save and from the Generate button. The field config lookup now goes through the schema map (keyed by schema path), which fixes the crash and handles blocks.
Custom slugify functions now also get siblingData. To generate from a field that is not a sibling, use a custom slugify as it receives the full document data.
Uniqueness is root-only: every uniqueness path addresses a collection-wide field by name, which a nested slug does not have. So a nested slug defaults unique and required to false, and skips dedupe, the collision check and the -N fallback.
Breaking changes
Builds on #17458.
Supersedes #14783.