feat: hierarchy with ui#15769
Merged
JarrodMFlesch merged 400 commits intomainfrom May 5, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete old folder-specific UI that's being replaced by unified taxonomy tree. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete old folder-specific backend utils and Next.js views. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add sanitizeFolder, validateFolderFields, getAncestors, and FolderSidebarTab. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Align folders with taxonomy system architecture. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update types and sanitization for folder/taxonomy alignment. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update Tree, TaxonomyTree, providers, and exports. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update views, exports, and server functions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update folder/taxonomy tests and minor config files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add new properties to HierarchyConfig and SanitizedHierarchyConfig: - allowHasMany: for folder (single) vs tag (multiple) behavior - collectionSpecific: for scoping to specific collections - admin.components.Icon: custom icon component - admin.treeLimit: max tree depth - relatedCollections: auto-populated during validation
Add defaults for allowHasMany, collectionSpecific, admin.treeLimit, admin.components.Icon, and slugify in sanitizeHierarchy. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Creates relationship field with hasMany:false, admin.hidden:true, and custom.hierarchy.injectHeaderButton marker for UI injection. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PatrikKozak
previously approved these changes
May 5, 2026
PatrikKozak
previously approved these changes
May 5, 2026
PatrikKozak
approved these changes
May 5, 2026
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.
Hierarchy Feature
This PR introduces a comprehensive hierarchy system for Payload that enables collections to have parent-child relationships with automatic path generation, dedicated sidebar navigation, and specialized UI components for folder and tag patterns.
Overview
The hierarchy feature allows any collection to define parent-child relationships through a declarative
hierarchyconfig property. When enabled, Payload automatically handles relationship management, path computation, circular reference prevention, and injects a dedicated sidebar tab with a tree view for navigation.At its core, hierarchy manages a
parentFieldNamerelationship field that references documents within the same collection. The system automatically creates this field if it doesn't exist, adds validation to prevent circular references (you can't move a folder into its own subfolder), and computes virtual path fields that provide breadcrumb-style paths from root to each document.Path Generation
Two virtual fields are automatically added to hierarchy-enabled collections:
_h_slugPathand_h_titlePath. These compute breadcrumb paths by walking up the parent chain to root during read operations. For example, a document nested three levels deep might have paths likeengineering/frontend/componentsandEngineering / Frontend / Components. Path computation is cached per-request to avoid redundant ancestor queries, and usesoverrideAccess: trueto ensure complete paths even when users lack read permission on intermediate ancestors.The field names are customizable via
slugPathFieldNameandtitlePathFieldNamein the hierarchy config. Path generation also respects localization, returning localized strings when the collection uses localized title fields.Sidebar Tabs
The hierarchy feature builds on a new sidebar tabs system that allows rendering custom tabs alongside the default Collections tab. Each hierarchy collection automatically gets its own tab injected during config resolution. The tab displays a tree view of the hierarchy with expand/collapse functionality, search, and optional collection-type filtering.
When you click a node in the tree, the list view filters to show only that node's children and related documents. The URL updates with a
?parent=<id>parameter, and the tree highlights the currently selected node. Expanded node state persists across sessions via payload-preferences.Folder and Tag Presets
Instead of wrapping your collection config in a HOC function, you now declare the preset directly on the collection config using the
foldersortagsproperty.folderspreset configures a folder-style hierarchy where each document can have only one parent (single-select). It enforcesallowHasMany: false, applies a default folder icon, and enables the miller columns header button by default. The collection is hidden from the main nav since it's accessed via its sidebar tab.tagspreset configures a tag-style hierarchy where documents can have multiple parents (multi-select by default). This is useful for categorization systems where items can belong to multiple categories.Both presets accept
truefor defaults, or a config object for customization.createFolderFieldcreates a relationship field for assigning a single folder to documents in other collections. The field renders as a header button that opens a miller columns drawer for folder selection instead of the standard relationship dropdown.createTagFieldcreates a relationship field for assigning multiple tags to documents. Unlike folder fields, tag fields use the standard relationship UI with hierarchy-aware features.Setup
To add hierarchy to a collection, add the
hierarchyproperty to your collection config:For folder patterns, use the
folderspreset directly on the collection config:For tag patterns, use the
tagspreset:Collection-Specific Folders
Folders can optionally restrict which collection types they accept. Enable this with
collectionSpecific:This adds a multi-select field to folders where you can specify which collections can be placed in that folder. When filtering the sidebar tree, only folders that accept the current collection type are shown.
Join Field
For querying all children of a hierarchy item (both nested items and related documents from other collections), configure the
joinFieldoption:This creates a virtual join field that aggregates all documents referencing each hierarchy item as their parent.
If you previously used
folders, migration to the new hierarchy system is straightforward, but you now need to define your folders collection explicitly (it is no longer created for you).To preserve existing folders data, keep the collection slug as
payload-foldersand setparentFieldNametofolder:Current UI
CleanShot.2026-03-17.at.08.26.22.mp4