Skip to content

feat(ui): add grid presentation infrastructure - #18414

Merged
JarrodMFlesch merged 31 commits into
mainfrom
codex/hierarchy-grid-infrastructure
Oct 6, 2026
Merged

JarrodMFlesch merged 31 commits into
mainfrom
codex/hierarchy-grid-infrastructure

Conversation

@JarrodMFlesch

@JarrodMFlesch JarrodMFlesch commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds reusable grid presentation infrastructure and enables a grid view for flat collections while keeping hierarchy collections on their existing table path.

Grid presentation

Introduces reusable CardGrid, DocumentCard, SegmentedControl, and LayoutToggle components. Collections can optionally define admin.useAsThumbnail, with the document icon used as a fallback when no thumbnail is available.

Grouped and hierarchy collections can use the same table or grid layouts while retaining their existing grouping, pagination, and navigation behavior.

Interaction and accessibility

Document cards support single-click selection, double-click navigation, keyboard selection, and a separately focusable title link for direct navigation.

Cards expose visible focus and selection states using shared design tokens. Layout controls use native radio semantics and provide “Table” and “Grid” tooltips on hover and keyboard focus.

Layout preferences and routing

The selected document layout is stored per collection as a preference and shared between the collection’s logical views.

Logical views such as all and hierarchy are represented in the view query parameter, allowing browser navigation to restore the correct view without conflating it with the table or grid layout.

Preference updates support functional setters to prevent rapid updates from overwriting one another, while list-query updates preserve unrelated route parameters.

Preview of navigation changes

  • Clicking hierarchy documents from list view, takes you to the "By [hierarchy label]" view
  • Toggling between grid/list view is saved in preferences per collection
  • Drilling into hierarchy documents keeps you in the same grid/list view based on prefs
CleanShot.2026-10-05.at.15.37.23.mp4

Preview of useAsThumbnail media card for upload collection

CleanShot.2026-10-05.at.15.43.07.mp4

Preview of useAsThumbnail media card for collection with upload field (relation)

CleanShot.2026-10-05.at.15.49.23.mp4

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖

Meta File Out File Size (raw) Note
packages/next/meta_index.json esbuild/index.js 216.84 KB 🆕 Added
packages/payload/meta_index.json esbuild/index.js 1.87 MB 🆕 Added
packages/payload/meta_shared.json esbuild/exports/shared.js 562.37 KB 🆕 Added
packages/richtext-lexical/meta_client.json esbuild/exports/client_optimized/index.js 296.14 KB 🆕 Added
packages/ui/meta_client.json esbuild/exports/client_optimized/index.js 37.43 KB 🆕 Added
packages/ui/meta_shared.json esbuild/exports/shared_optimized/index.js 18.98 KB 🆕 Added
Largest paths These visualization shows top 20 largest paths in the bundle.

Meta file: packages/next/meta_index.json, Out file: esbuild/index.js

Path Size
../../node_modules ${{\color{Goldenrod}{ ████████████████████████▋ }}}$ 98.8%, 212.32 KB
dist/adapters/router.js ${{\color{Goldenrod}{ }}}$ 0.3%, 718 B
dist/adapters/server.js ${{\color{Goldenrod}{ }}}$ 0.2%, 533 B
dist/adapters/layout.js ${{\color{Goldenrod}{ }}}$ 0.2%, 529 B
dist/adapters/views.js ${{\color{Goldenrod}{ }}}$ 0.2%, 324 B
dist/utilities/initAdminContext.js ${{\color{Goldenrod}{ }}}$ 0.1%, 315 B
dist/utilities/selectiveCache.js ${{\color{Goldenrod}{ }}}$ 0.1%, 263 B
dist/esbuildEntry.js ${{\color{Goldenrod}{ }}}$ 0.0%, 0 B

Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js

Path Size
../../node_modules ${{\color{Goldenrod}{ █████████████████▉ }}}$ 71.9%, 1.34 MB
dist/collections/operations ${{\color{Goldenrod}{ ▋ }}}$ 2.9%, 54.65 KB
dist/fields/hooks ${{\color{Goldenrod}{ ▋ }}}$ 2.5%, 46.15 KB
dist/auth/operations ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 16.95 KB
dist/globals/operations ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 16.18 KB
dist/utilities/configToJSONSchema.js ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 16.02 KB
dist/queues/operations ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 14.31 KB
dist/fields/config ${{\color{Goldenrod}{ ▏ }}}$ 0.7%, 13.65 KB
dist/utilities/telemetry ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 11.88 KB
dist/collections/config ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 11.74 KB
dist/fields/validations.js ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 10.82 KB
dist/cli/commands ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 9.92 KB
dist/config/orderable ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 8.76 KB
dist/uploads/fetchAPI-multipart ${{\color{Goldenrod}{ }}}$ 0.4%, 8.38 KB
dist/database/migrations ${{\color{Goldenrod}{ }}}$ 0.4%, 8.16 KB
dist/config/sanitize.js ${{\color{Goldenrod}{ }}}$ 0.4%, 7.95 KB
dist/index.js ${{\color{Goldenrod}{ }}}$ 0.4%, 7.79 KB
dist/hierarchy/utils ${{\color{Goldenrod}{ }}}$ 0.4%, 7.66 KB
dist/auth/strategies ${{\color{Goldenrod}{ }}}$ 0.4%, 7.36 KB
dist/utilities/entityInputSchema ${{\color{Goldenrod}{ }}}$ 0.4%, 7.34 KB
(other) ${{\color{Goldenrod}{ ███████ }}}$ 28.1%, 524.37 KB

Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js

Path Size
../../node_modules ${{\color{Goldenrod}{ ██████████████████████▏ }}}$ 88.9%, 495.80 KB
dist/fields/validations.js ${{\color{Goldenrod}{ ▍ }}}$ 1.9%, 10.79 KB
dist/fields/config ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 5.83 KB
dist/utilities/traverseFields.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 4.34 KB
dist/utilities/deepCopyObject.js ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.52 KB
dist/collections/config ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.42 KB
dist/config/orderable ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.13 KB
dist/fields/baseFields ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 2.79 KB
dist/config/client.js ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 2.56 KB
dist/auth/cookies.js ${{\color{Goldenrod}{ }}}$ 0.3%, 1.55 KB
dist/utilities/flattenTopLevelFields.js ${{\color{Goldenrod}{ }}}$ 0.3%, 1.42 KB
dist/utilities/getVersionsConfig.js ${{\color{Goldenrod}{ }}}$ 0.2%, 1.04 KB
dist/globals/config ${{\color{Goldenrod}{ }}}$ 0.2%, 939 B
dist/utilities/unflatten.js ${{\color{Goldenrod}{ }}}$ 0.2%, 850 B
dist/utilities/flattenAllFields.js ${{\color{Goldenrod}{ }}}$ 0.1%, 798 B
dist/utilities/sanitizeUserDataForEmail.js ${{\color{Goldenrod}{ }}}$ 0.1%, 713 B
dist/auth/extractJWT.js ${{\color{Goldenrod}{ }}}$ 0.1%, 696 B
dist/utilities/getFieldPermissions.js ${{\color{Goldenrod}{ }}}$ 0.1%, 651 B
dist/utilities/fieldPath.js ${{\color{Goldenrod}{ }}}$ 0.1%, 639 B
dist/utilities/getSafeRedirect.js ${{\color{Goldenrod}{ }}}$ 0.1%, 632 B
(other) ${{\color{Goldenrod}{ ██▊ }}}$ 11.1%, 61.69 KB

Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js

Path Size
dist/features/blocks ${{\color{Goldenrod}{ ███▋ }}}$ 14.6%, 42.74 KB
dist/lexical/plugins ${{\color{Goldenrod}{ ██▉ }}}$ 11.8%, 34.51 KB
dist/lexical/ui ${{\color{Goldenrod}{ ██▊ }}}$ 11.4%, 33.54 KB
dist/features/table ${{\color{Goldenrod}{ ██▎ }}}$ 9.4%, 27.46 KB
dist/features/link ${{\color{Goldenrod}{ █▋ }}}$ 6.5%, 18.92 KB
dist/features/toolbars ${{\color{Goldenrod}{ █▌ }}}$ 6.3%, 18.41 KB
dist/features/upload ${{\color{Goldenrod}{ █▏ }}}$ 4.9%, 14.28 KB
dist/features/textState ${{\color{Goldenrod}{ ▉ }}}$ 3.8%, 11.08 KB
dist/lexical/utils ${{\color{Goldenrod}{ ▊ }}}$ 3.4%, 10.02 KB
dist/features/relationship ${{\color{Goldenrod}{ ▊ }}}$ 3.2%, 9.43 KB
dist/features/converters ${{\color{Goldenrod}{ ▋ }}}$ 2.9%, 8.40 KB
dist/utilities/fieldsDrawer ${{\color{Goldenrod}{ ▋ }}}$ 2.8%, 8.12 KB
dist/features/debug ${{\color{Goldenrod}{ ▋ }}}$ 2.5%, 7.40 KB
dist/lexical/config ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 5.14 KB
dist/features/indent ${{\color{Goldenrod}{ ▎ }}}$ 1.4%, 4.19 KB
dist/features/lists ${{\color{Goldenrod}{ ▎ }}}$ 1.3%, 3.67 KB
dist/lexical/LexicalEditor.js ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.33 KB
dist/features/format ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.28 KB
dist/features/horizontalRule ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.18 KB
dist/field/Field.js ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 3.05 KB
(other) ${{\color{Goldenrod}{ █████████████████████▎ }}}$ 85.4%, 250.19 KB

Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js

Path Size
dist/exports/client ${{\color{Goldenrod}{ █████████████████████████ }}}$ 100.0%, 27.59 KB

Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js

Path Size
dist/graphics/Logo ${{\color{Goldenrod}{ ███████▋ }}}$ 30.7%, 5.61 KB
../../node_modules ${{\color{Goldenrod}{ ███▌ }}}$ 14.5%, 2.65 KB
dist/graphics/Icon ${{\color{Goldenrod}{ ██ }}}$ 8.3%, 1.51 KB
dist/utilities/formatDocTitle ${{\color{Goldenrod}{ █▊ }}}$ 7.2%, 1.32 KB
dist/providers/TableColumns ${{\color{Goldenrod}{ █▏ }}}$ 4.7%, 866 B
dist/utilities/getGlobalData.js ${{\color{Goldenrod}{ █ }}}$ 4.2%, 762 B
dist/utilities/api.js ${{\color{Goldenrod}{ █ }}}$ 4.1%, 756 B
dist/utilities/groupNavItems.js ${{\color{Goldenrod}{ █ }}}$ 4.1%, 745 B
dist/elements/Translation ${{\color{Goldenrod}{ ▋ }}}$ 2.7%, 493 B
dist/utilities/handleTakeOver.js ${{\color{Goldenrod}{ ▌ }}}$ 2.4%, 440 B
dist/utilities/traverseForLocalizedFields.js ${{\color{Goldenrod}{ ▌ }}}$ 2.3%, 419 B
dist/elements/withMergedProps ${{\color{Goldenrod}{ ▍ }}}$ 1.9%, 339 B
dist/utilities/getNavGroups.js ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 338 B
dist/utilities/getVisibleEntities.js ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 329 B
dist/elements/WithServerSideProps ${{\color{Goldenrod}{ ▎ }}}$ 1.3%, 232 B
dist/layouts/Root ${{\color{Goldenrod}{ ▎ }}}$ 1.3%, 230 B
dist/utilities/handleGoBack.js ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 180 B
dist/fields/mergeFieldStyles.js ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 158 B
dist/forms/Form ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 152 B
dist/utilities/handleBackToDashboard.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 152 B
(other) ${{\color{Goldenrod}{ █████████████████▎ }}}$ 69.3%, 12.68 KB
Details

Next to the size is how much the size has increased or decreased compared with the base branch of this PR.

  • ‼️: Size increased by 20% or more. Special attention should be given to this.
  • ⚠️: Size increased in acceptable range (lower than 20%).
  • ✅: No change or even downsized.
  • 🗑️: The out file is deleted: not found in base branch.
  • 🆕: The out file is newly found: will be added to base branch.

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Written by AI

Requesting changes for three regressions in the grid presentation:

  1. Missing thumbnails can crash the list. When a configured hasMany upload field is empty or contains only unpopulated IDs, getThumbnailDoc returns undefined, and DocumentGrid dereferences .mimeType. These documents should render the thumbnail placeholder.
  2. A saved grid preference breaks document selection in ListDrawers. Relationship/upload pickers inherit the collection's grid preference, but grid cards update bulk selection rather than invoking the drawer's onSelect. Keep drawers on the table selection path until grid cards support their selection contract.
  3. Grid navigation bypasses admin.formatDocURL. Cards use the default document URL, ignoring both custom destinations and null results that disable links. Resolve these URLs on the server and preserve disabled navigation in the card.

I've opened #18529 against this PR's branch (codex/hierarchy-grid-infrastructure) with fixes and regression coverage. Please review that follow-up PR for integration here. Its 10 unit tests, 6 browser component tests, and 9 end-to-end tests passed, along with type checks, lint, and formatting. Manual visual focus and screen-reader verification remain documented there.

Written by AI

## Description

Fixes the three review findings from #18414. This PR targets
`codex/hierarchy-grid-infrastructure`.

## Changes

- Render the thumbnail placeholder when a configured upload field is
empty or contains only unpopulated IDs.
- Keep relationship and upload ListDrawers on the table selection path
even when the collection has a saved grid preference.
- Resolve `admin.formatDocURL` on the server for flat and grouped grids,
sharing URL resolution with table cells. A null result renders a title
without a link and prevents double-click navigation while preserving
permitted selection.
- Honor `enableRowSelections` in grid cards.

## Test Plan

- URL and thumbnail unit suites: 10 tests passed.
- DocumentCard and DocumentGrid browser component suites: 6 tests
passed.
- List-view `formatDocURL` and saved-grid drawer regressions: 8 tests
passed with SQLite.
- WCAG 2.1.1 real rich-text relationship picker regression: 1 test
passed with SQLite.
- Payload/translations TypeScript builds and UI type check passed.
- ESLint: no errors; existing warnings and ignored colocated specs.
Prettier and `git diff --check` passed.

Browser checks used locally available Chrome/Chromium executables;
temporary runner configuration changes are excluded from the PR.

### Accessibility assessment

Assessed missing thumbnails, linked and unlinked cards, optional
selection, and the relationship picker after saving grid layout. Browser
tests cover mouse activation, Enter/Space selection, disabled
navigation, and selecting a real relationship with Enter.

Criteria considered: 1.1.1 (thumbnail fallback), 1.3.1 and 4.1.2
(link/button semantics and selection state), 2.1.1 (keyboard operation),
2.4.3 and 2.4.4 (focus order and link purpose), 2.4.7/2.4.11 (focus
visibility), 2.5.2 (pointer activation), and 3.2.1 (focus does not
trigger navigation). Styling and target sizes are unchanged.

Visual focus/occlusion and screen-reader announcements still need human
verification. No axe or screen-reader run was performed; these checks do
not establish full WCAG conformance.

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found one little nit, not blocking. Looks good

)
}

const fields = flattenTopLevelFields(config.fields)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't we have config.flattenedFields already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will address in a separate PR. Requires some function call shuffling, but possible.

@JarrodMFlesch
JarrodMFlesch merged commit 75e61a0 into main Oct 6, 2026
281 of 283 checks passed
@JarrodMFlesch
JarrodMFlesch deleted the codex/hierarchy-grid-infrastructure branch October 6, 2026 14:48
JarrodMFlesch added a commit that referenced this pull request Oct 6, 2026
Requires #18414

Localizes the layout group and its Table/Grid radio labels across all
supported locales, and translates the complete DocumentCard selection
instructions. The translated labels are reused for accessible names and
the existing hover/focus tooltips.

Addressed comment from
#18414 (comment)
paulpopus added a commit that referenced this pull request Oct 6, 2026
## Summary

This PR updates the upload select unit test for the Payload 4 variants
contract. The test now uses `upload.variants` and verifies
`select.variants`.

## Why

[#18414](#18414) added the
test against the former `imageSizes` and `sizes` names.
[#17827](#17827) merged after
that test's last successful CI run and changed the production contract
to `variants`.

## Validation

- The complete unit suite passes with 3,625 tests.
- The React Server Component suite passes with two tests.
- The audit found no other test fixtures or select assertions that use
the removed contract.
- Prettier and `git diff --check` pass.

Written with AI
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants