Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Preview View Custom Component is not working #8273

Closed
tsemachh opened this issue Sep 18, 2024 · 5 comments
Closed

Live Preview View Custom Component is not working #8273

tsemachh opened this issue Sep 18, 2024 · 5 comments
Assignees
Labels

Comments

@tsemachh
Copy link

Link to reproduction

No response

Environment Info

Node.js v22.8.0

Binaries:
  Node: 22.8.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.4.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/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
Operating System:
  Platform: linux
  Arch: x64
  Version: #44-Ubuntu SMP PREEMPT_DYNAMIC Tue Aug 13 13:35:26 UTC 2024
  Available memory (MB): 31817
  Available CPU cores: 8

Describe the Bug

We try and follow documentation at:
https://payloadcms.com/docs/beta/admin/views#document-views

livePreview The LivePreview view is used to display the Live Preview interface. It is rendered within the "Live Preview" tab. More details.

But this is not working because of missing code which should handle it.
File: packages/next/src/views/Document/getViewsFromConfig.tsx - Lines 312-325

            case 'preview': {
              if (livePreviewEnabled) {
                DefaultView = {
                  Component: DefaultLivePreviewView,
                }
              }
              break
            }

            case 'versions': {
              if (!overrideDocPermissions && docPermissions?.readVersions?.permission) {
                CustomView = {
                  payloadComponent: getCustomViewByKey(views, 'versions'),
                }

The preview case is not handling the CustomView - aka:

CustomView = {
                  payloadComponent: getCustomViewByKey(views, 'livePreview'),
                }

Reproduction Steps

In payload.config.ts define next customization in one of the Collections:

components: {
      views: {
        edit: {
          default: {
            Component: '/components/views/CustomDefaultEditView',
          },
          livePreview: {
            Component: '/components/views/LivePreview/LivePreviewView'
          }
        },
      },
    }

Expected behavior is that customized live preview view will replace default live preview view , but we got the default.

Adapters and Plugins

No response

@tsemachh tsemachh added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Sep 18, 2024
@tsemachh tsemachh changed the title Live Preview Custom Component is not working Live Preview View Custom Component is not working Sep 18, 2024
@tsemachh
Copy link
Author

If needed I can post a PR , not a big change

@paulpopus paulpopus self-assigned this Sep 20, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Sep 20, 2024
@malifon

This comment has been minimized.

@kendelljoseph
Copy link
Contributor

PR is opened that addresses this issue.
#8930

Copy link

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2024
@paulpopus
Copy link
Contributor

This is released as of beta 122 I believe

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants