Rich Text Field Not Rendering in DefaultEditView #12600
Replies: 1 comment 1 reply
-
Moved to a discussion, as this is an issue with the custom code and not with payload (the issues section is reserved for payload issues only). The lexical field is a react server component - those have to be rendered on the server first before they can be displayed on the client. Thus this issue is will happen with custom field components that are RSCs as well. The initial state you pass to the document info provider likely does not contain the rendered RSCs. Once you add an array row, the form state response will contain the rendered RSCs, which is why the richtext field then appears. You will have to properly create the initial state on the server rather than constructing it on the client ( Check out https://github.com/payloadcms/payload/blob/main/packages/ui/src/utilities/buildFormState.ts - this will eventually call a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the Bug
Rich Text Fields Not Rendering in Custom Drawer but Work When Adding New Comments
Issue Description
When using a custom task drawer implementation, rich text fields don't render properly when initially loaded but oddly work fine when adding new array elements that have a richtext field. This issue occurs despite using Payload's default components.
Reproduction Steps
/admin/views/kanban
I've tried both the custom TaskDrawerContent component and Payload's DefaultEditView component, and both exhibit the same issue.
Technical Details
What Works
What Doesn't Work
DefaultEditView
component directly doesn't solve the issueRelevant File Paths
/src/views/kanban/index.tsx
- Main Kanban view component/src/views/kanban/TaskDrawer.tsx
- Custom drawer implementation/src/views/kanban/TaskDrawerContent.tsx
- Our simplified version of DefaultEditView/src/views/kanban/TaskDrawerProvider.tsx
- Context provider for the drawer/src/views/kanban/TaskButton.tsx
- Button to open the drawer with example task/src/collections/Tasks/index.ts
- Task collection definition with rich text fields/src/app/(payload)/admin/importMap.js
- Import map for Lexical editor componentsImplementation Details
The issue is in our custom task drawer implementation in
/src/views/kanban/TaskDrawer.tsx
. We're using Payload'sDocumentInfoProvider
and trying both:TaskDrawerContent
componentDefaultEditView
componentBoth approaches have the same issue - rich text doesn't render initially, but works when adding new comments.
In
TaskDrawer.tsx
, we're switching between our component and Payload's default:The rich text fields are properly configured in our Task collection
/src/collections/Tasks/index.ts
:Possible Causes
Expected Behavior
Rich text fields should render properly in the custom drawer implementation, just like they do in the standard Payload admin UI and when adding new comments.
Link to the code that reproduces this issue
https://github.com/cgilly2fast/rich-text-rendering-issus
Reproduction Steps
Reproduction Steps
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
Beta Was this translation helpful? Give feedback.
All reactions