Skip to content

Commit

Permalink
fix(ui): ensures list drawer does not change underlying step nav (#10339
Browse files Browse the repository at this point in the history
)

When opening the list drawer, such as when selecting an existing upload,
the underlying step nav of the document view changes but shouldn't.
  • Loading branch information
jacobsfletch authored Jan 3, 2025
1 parent ba228dd commit b44aade
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/views/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
])

useEffect(() => {
if (drawerDepth <= 1) {
if (!drawerDepth) {
setStepNav([
{
label: labels?.plural,
Expand Down
7 changes: 6 additions & 1 deletion test/admin/collections/Posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { CollectionConfig } from 'payload'
import { slateEditor } from '@payloadcms/richtext-slate'

import { slugPluralLabel, slugSingularLabel } from '../shared.js'
import { postsCollectionSlug } from '../slugs.js'
import { postsCollectionSlug, uploadCollectionSlug } from '../slugs.js'

export const Posts: CollectionConfig = {
slug: postsCollectionSlug,
Expand Down Expand Up @@ -182,6 +182,11 @@ export const Posts: CollectionConfig = {
},
},
},
{
name: 'upload',
type: 'upload',
relationTo: uploadCollectionSlug,
},
{
name: 'hiddenField',
type: 'text',
Expand Down
22 changes: 22 additions & 0 deletions test/admin/e2e/document-view/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,28 @@ describe('Document View', () => {
})
})

describe('breadcrumbs', () => {
test('List drawer should not effect underlying breadcrumbs', async () => {
await navigateToDoc(page, postsUrl)

expect(await page.locator('.step-nav.app-header__step-nav a').nth(1).innerText()).toBe(
'Posts',
)

await page.locator('#field-upload button.upload__listToggler').click()
await expect(page.locator('[id^=list-drawer_1_]')).toBeVisible()
await wait(100) // wait for the component to re-render

await expect(
page.locator('.step-nav.app-header__step-nav .step-nav__last'),
).not.toContainText('Uploads')

expect(await page.locator('.step-nav.app-header__step-nav a').nth(1).innerText()).toBe(
'Posts',
)
})
})

describe('custom document views', () => {
test('collection — should render custom tab view', async () => {
await page.goto(customViewsURL.create)
Expand Down

0 comments on commit b44aade

Please sign in to comment.