feat(next, ui): widget fields#15700
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
|
@GermanJablo I've opened a new pull request, #15730, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@copilot I just wanted you to review this PR 😅 |
|
@GermanJablo I've opened a new pull request, #15731, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
Okay, I figured out how to do it, but you should be smarter. Bad bot! |
There was a problem hiding this comment.
Pull request overview
This PR adds configurable fields support to dashboard widgets, enabling widget customization through a new drawer UI in editing mode. The feature includes full type generation with generic WidgetInstance<T> and WidgetServerProps<T> types that provide typed data and width based on widget field schemas and min/max width constraints.
Changes:
- Added
fieldsconfiguration to widget definitions, allowing widgets to declare form fields similar to Blocks - Implemented widget data editing via a new drawer UI (accessible through edit button) when dashboard is in editing mode
- Full TypeScript type generation for widget instances with typed
dataand constrainedwidthproperties
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/dashboard/utils.ts | Updated test helper to support widget editing and improved width button visibility checking |
| test/dashboard/payload-types.ts | Generated TypeScript types for widget instances with typed data and width constraints |
| test/dashboard/e2e.spec.ts | Added E2E tests for widget data editing, persistence, and cancellation flows |
| test/dashboard/config.ts | Updated config to include widget field definitions and default widget data |
| test/dashboard/components/Revenue.tsx | Updated Revenue widget to use typed widgetData from WidgetServerProps |
| test/dashboard/components/Count.tsx | Updated Count widget to use typed widgetData and dynamic collection selection |
| packages/ui/src/utilities/getSchemaMap.ts | Extended schema map caching to support widgetSlug with widget-specific cache keys |
| packages/ui/src/utilities/getClientSchemaMap.ts | Extended client schema map to support widget field schemas |
| packages/ui/src/utilities/buildFormState.ts | Added widgetSlug parameter for building form state from widget fields |
| packages/ui/src/utilities/buildFieldSchemaMap/index.ts | Added widget field schema building alongside collections and globals |
| packages/ui/src/utilities/buildClientFieldSchemaMap/index.ts | Added client-side widget field schema processing |
| packages/payload/src/utilities/configToJSONSchema.ts | Added widget schema generation with field types and width constraints |
| packages/payload/src/index.ts | Added TypedWidget, WidgetSlug, and DataFromWidgetSlug type utilities |
| packages/payload/src/config/types.ts | Updated Widget and WidgetInstance types to support fields and typed data/width |
| packages/payload/src/config/sanitize.ts | Added widget field sanitization during config processing |
| packages/payload/src/config/client.ts | Added client widget field processing and label resolution |
| packages/payload/src/bin/generateImportMap/iterateConfig.ts | Added import map iteration for widget field components |
| packages/payload/src/admin/views/dashboard.ts | Enhanced WidgetServerProps with generic type parameter for typed widgetData |
| packages/payload/src/admin/forms/Form.ts | Extended BuildFormStateArgs to support widgetSlug |
| packages/next/src/views/Dashboard/.../useDashboardLayout.ts | Added updateWidgetData function and data change detection |
| packages/next/src/views/Dashboard/.../renderWidget/renderWidgetServerFn.ts | Added widgetData parameter passing through server function |
| packages/next/src/views/Dashboard/.../renderWidget/getDefaultLayoutServerFn.ts | Added widgetData extraction from layout instances |
| packages/next/src/views/Dashboard/.../renderWidget/RenderWidget.tsx | Enhanced with request ID tracking to prevent race conditions |
| packages/next/src/views/Dashboard/.../index.tsx | Added widget data to item mapping and component props |
| packages/next/src/views/Dashboard/.../index.scss | Updated focus styles to use focus-visible for better accessibility |
| packages/next/src/views/Dashboard/.../index.client.tsx | Added WidgetEditControl and updated data tracking in WidgetItem |
| packages/next/src/views/Dashboard/.../WidgetEditControl.tsx | New component for widget edit button with conditional rendering |
| packages/next/src/views/Dashboard/.../WidgetConfigDrawer.tsx | New drawer component for editing widget field data |
| docs/custom-components/dashboard.mdx | Updated documentation with widget fields examples and usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
paulpopus
left a comment
There was a problem hiding this comment.
Left some comments.
We should trigger the "LeaveWithoutSaving" modal if changes are made to fields but not saved, it can be a bit confusing that the modal says "save" but actually its not submitted until you save the dashboard layout itself.
Or maybe we need to think about the UX here as its easy to lose changes made in the modals
paulpopus
left a comment
There was a problem hiding this comment.
- Localisation works now in the given example but it doesn't work with nested fields:
{
type: 'group',
name: 'nestedGroup',
fields: [
{
name: 'nestedText',
type: 'text',
localized: true,
},
],
},- When I make content changes in a widget I can still navigate away without being blocked by a LeaveWithoutSaving modal so it's easy to lose changes made
|
🚀 This is included in version v3.78.0 |
Summary
fieldssupport to dashboard widgets, analogous to how Blocks work — widgets can now declare configurable fieldsWidgetInstance<T>is now generic with typeddataandwidthbased on the widget's field schema and min/max width constraintsWidgetServerPropsis generic so widget components receive typedwidgetDataUsage
Demo
Screen.Recording.2026-02-23.at.16.25.40.mov