payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
25.09k stars 1.6k forks source link

Live preview does not render edit custom view #8883

Open dvorac20 opened 1 week ago

dvorac20 commented 1 week ago

Describe the Bug

When we defined a custom view for a collection, in the edit view the custom view is displayed, After saving the page and moving to live preview the custom view disapears and the default view is shown

Link to the code that reproduces this issue

https://github.com/shefing/payload_custom_edit_view

Reproduction Steps

Steps to reproduce:

  1. Clone the link to reproduction ripo and launch Payload (test/ live-preview)
  2. Create a new Post instance
  3. Save the page
  4. Move to live preview tab

Expected: Custom view will display.

Actual: Default view displayed instead of custom view

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Output from 'pnpm payload info': Binaries: Node: 20.9.0 npm: 10.2.5 Yarn: 1.22.21 pnpm: 9.10.0 Relevant Packages: payload: 3.0.0-beta.104 next: 15.0.0-canary.104 @payloadcms/db-mongodb: 3.0.0-beta.104 @payloadcms/graphql: 3.0.0-beta.104 @payloadcms/live-preview: 3.0.0-beta.104 @payloadcms/next/utilities: 3.0.0-beta.104 @payloadcms/plugin-cloud-storage: 3.0.0-beta.104 @payloadcms/plugin-redirects: 3.0.0-beta.104 @payloadcms/plugin-seo: 3.0.0-beta.104 @payloadcms/richtext-lexical: 3.0.0-beta.104 @payloadcms/storage-s3: 3.0.0-beta.104 @payloadcms/translations: 3.0.0-beta.104 @payloadcms/ui/shared: 3.0.0-beta.104 react: 19.0.0-rc-06d0b89e-20240801 react-dom: 19.0.0-rc-06d0b89e-20240801

paulpopus commented 1 week ago

This should be fixed as of beta 122 https://github.com/payloadcms/payload/pull/8930

tsemachh commented 1 week ago

@paulpopus it's not fixed. This issue handles next use case:

I expect when I move to Live Preview to have same Custom View A with Live Preview on the right panel(or as popup). In our case we have View with Comments at the right panel and user expects to have it also in live preview. Of course we can use custom view with double logic of the comments but it's not a good solution. I suggest instead of rendering the fields in live preview - check if custom edit view is provided and render it there instead