Skip to content

Live preview sidebar doesn't update if slug updates #13055

Closed as duplicate
Closed as duplicate

Description

@PP-Tom

Describe the Bug.

I believe this might be a difficult one to fix, now that the live preview is attached to the document root, if you create a document and then type a title to generate a slug, the live preview doesn't update to that slug as it takes the URL when the live preview mounts.

I'm not entirely sure how to fix this as refreshing on form changes could cause performance problems.

My suggestion would potentially add a refresh button here;
Image

Or revalidate the URL on toggling live preview. In the meantime I believe this could be fixed in the FE.

Reproduction Steps

  1. Use the Website Template
  2. Create a new document
  3. Press live preview
  4. Create a slug
  5. Live preview doesn't update

Environment Info

Payload: 3.45.0
NextJS: 15.3.2
NodeJS: 22.0

Activity

  1. added
    status: needs-triage
    area: ui
    on Jul 7, 2025
  2. jacobsfletch commented on Jul 7, 2025

    @jacobsfletch
    Member

    @PP-Tom this was always an issue, even before mounting live preview to root. This is something I've always wanted to fix. If your URL relies on dynamic data from the document, it needs to be refreshed. See #12785

    I'm not entirely sure how to fix this as refreshing on form changes could cause performance problems.

    This is true, but technically it would only run when a field changes that might affect the url. There are ways to optimize this, like only generate the slug on initial create or when explicitly requested, not on every keypress. This specific issue is being addressed here: #12956

    But the other performance implication here is running the live preview url function itself. We either need to run it on every form state change, or find some pattern for opt-in to re-running it when certain criteria are met.

    Then if the URL does in fact change, we'd also need to reestablish a connection to the preview window.

  3. PP-Tom commented on Jul 7, 2025

    @PP-Tom
    Author

    Thanks for the insight @jacobsfletch, I didn't come across this before personally as I would create the title (generating the slug) and then click "Live Preview", in which now that isn't possible as clicking "Live Preview" doesn't refresh anything as it did before because you changed route.

    Previously if you were in live preview and then created a slug, you would face the same problem. But now the only way is to create the slug and either come out of the document and go back in, or refresh the browser.

    That's why I was thinking a refresh button on the Live Preview responsive bar could be a quick way around this as it doesn't mean you have to come out of the document in anyway.

    I'm interested in the creating a slug on initial create though, would this be similar to say Storyblok where you have to define a title and slug before creating the document?

  4. joetifa2003 commented on Jul 13, 2025

    @joetifa2003

    Maybe give us form data onRefresh in live reload, and then we can opt in to generate a url from the form and do a navigation, currently onRefersh takes no args.

  5. self-assigned this
    on Aug 11, 2025
  6. removed
    status: needs-triage
    on Aug 11, 2025
  7. jacobsfletch commented on Aug 27, 2025

    @jacobsfletch
    Member

    That's why I was thinking a refresh button on the Live Preview responsive bar could be a quick way around this as it doesn't mean you have to come out of the document in anyway.

    I'm not opposed to this. Would be a good feature either way!

    I'm interested in the creating a slug on initial create though, would this be similar to say Storyblok where you have to define a title and slug before creating the document?

    Not quite, just imagine a hook that auto populates the slug only if it doesn't exist yet. Autosave is where this gets tricky, though.

    I'm going to close this issue as a duplicate of #12785 which was opened first. Didn't see this before. But I'm actively working on it in #13631, let's track progress there.

  8. github-actions commented on Sep 5, 2025

    @github-actions
    Contributor

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

  9. locked as resolved and limited conversation to collaborators on Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: ui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions