-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Breadcrumbs not working when using DefaultTemplate with a CustomRootView #12344
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
Comments
Please add a reproduction in order for us to be able to investigate. Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided. Why was this issue marked with the
|
I tried setting the steps manually with: export const CustomDefaultRootView: React.FC<AdminViewServerProps> = ({
initPageResult,
params,
searchParams,
}) => {
const nav = [
{ label: "Dashboard", url: "/admin" },
{ label: "Custom Default View", url: "/admin/custom-default" },
];
return (
<StepNavProvider>
<DefaultTemplate
i18n={initPageResult.req.i18n}
locale={initPageResult.locale}
params={params}
payload={initPageResult.req.payload}
permissions={initPageResult.permissions}
searchParams={searchParams}
user={initPageResult.req.user || undefined}
visibleEntities={initPageResult.visibleEntities}
>
<SetStepNav nav={nav} />
<Gutter>
<h1>Custom Default Root View</h1>
<br />
<p>This view uses the Default Template.</p>
<CheckSteps />
</Gutter>
</DefaultTemplate>
</StepNavProvider>
);
}; but the steps are still an empty [] |
Here is my decent enough workaround until this gets resolved. 'use client'
import { HomeIcon } from 'lucide-react'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import React from 'react'
export default function Icon() {
const pathname = usePathname()
const icon = <HomeIcon size={17} className="text-primary" />
if (pathname === '/admin/analytics') {
return <Link href="/admin">{icon}</Link>
}
return icon
} |
I was supposed to use the import type { AdminViewServerProps } from 'payload'
import { DefaultTemplate } from '@payloadcms/next/templates'
import { Gutter, SetStepNav } from '@payloadcms/ui'
const AnalyticsDefaultRootView: React.FC<AdminViewServerProps> = ({
initPageResult,
params,
searchParams,
}) => {
const navItem = [
{
label: 'Analytics',
url: '/analytics',
},
]
return (
<DefaultTemplate
i18n={initPageResult.req.i18n}
locale={initPageResult.locale}
params={params}
payload={initPageResult.req.payload}
permissions={initPageResult.permissions}
searchParams={searchParams}
user={initPageResult.req.user || undefined}
visibleEntities={initPageResult.visibleEntities}
>
<SetStepNav nav={navItem} /> // This sets the bread crumbs
<Gutter>
<iframe
src="https://analytics.mikecebul.dev/share/<key>/basesmi.org"
width="100%"
height="100%"
style={{ border: 'none', overflow: 'hidden', minHeight: '85dvh' }}
title="Analytics"
allowFullScreen
loading="lazy"
/>
</Gutter>
</DefaultTemplate>
)
}
export default AnalyticsDefaultRootView |
This issue has been automatically locked. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the Bug
When using a CustomRootView I want to use the DefaultTemplate, but the breadcrumbs in the navbar isn't working to navigate back to home (to "/admin"). Looking at the source code it appears stepNav.length < 1 resulting in it rendering a
<div />
instead of an<a />
.Plus when you navigate to any page in the admin panel like "/admin/pages" and back to "/admin/custom-default" the breadcrumbs component does not update without a browser refresh.
Link to the code that reproduces this issue
create-payload-app --example custom-components
Reproduction Steps
custom-view-issue.mov
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
The text was updated successfully, but these errors were encountered: