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
23.56k stars 1.5k forks source link

Nav links in Custom View using DefaultTemplate mismatch after page refresh #6823

Closed tomashco closed 1 month ago

tomashco commented 3 months ago

Link to reproduction

No response

Payload Version

3.0.0-beta.50

Node Version

v20.10.0

Next.js Version

15.0.0-rc.0

Describe the Bug

I can correctly import my Custom View component wrapped inside DefaultTemplate, but the Navbar is not populated if you link directly to the Custom View page.

This is what I found after digging a bit: The navigation context lives in the client and for what I understood there is no way to get it from server side. Thus if you do the navigation adding your link to the custom view through the afterNavLinks array of components, there will not be a full refresh of the page, thus the navigation context will be preserved and you will be able to continue to see the nav links.

On the other hand, hitting directly the custom-view route you will not have the navigation, thus you will be able to see only the afterNavLinks components, but not all the other links. The same happens if you navigate to the Custom View using the afterNavLinks and then you refresh the page, as described in the Reproduction Steps.

Reproduction Steps

in payload repo run pnpm dev admin

  1. go to default template in the left navbar
  2. refresh the page
  3. all the nav items are lost, except the custom ones

before refresh: Screenshot 2024-06-18 at 09 50 36

after refresh: Screenshot 2024-06-18 at 09 50 46

Adapters and Plugins

No response

benjosua commented 3 months ago

I have exactly the same issue.

JarrodMFlesch commented 1 month ago

Fixed in https://github.com/payloadcms/payload/pull/7545

Will be available after next beta release

github-actions[bot] commented 3 weeks ago

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