Skip to content

Commit b44aade

Browse files
authored
fix(ui): ensures list drawer does not change underlying step nav (#10339)
When opening the list drawer, such as when selecting an existing upload, the underlying step nav of the document view changes but shouldn't.
1 parent ba228dd commit b44aade

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

packages/ui/src/views/List/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
163163
])
164164

165165
useEffect(() => {
166-
if (drawerDepth <= 1) {
166+
if (!drawerDepth) {
167167
setStepNav([
168168
{
169169
label: labels?.plural,

test/admin/collections/Posts.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CollectionConfig } from 'payload'
33
import { slateEditor } from '@payloadcms/richtext-slate'
44

55
import { slugPluralLabel, slugSingularLabel } from '../shared.js'
6-
import { postsCollectionSlug } from '../slugs.js'
6+
import { postsCollectionSlug, uploadCollectionSlug } from '../slugs.js'
77

88
export const Posts: CollectionConfig = {
99
slug: postsCollectionSlug,
@@ -182,6 +182,11 @@ export const Posts: CollectionConfig = {
182182
},
183183
},
184184
},
185+
{
186+
name: 'upload',
187+
type: 'upload',
188+
relationTo: uploadCollectionSlug,
189+
},
185190
{
186191
name: 'hiddenField',
187192
type: 'text',

test/admin/e2e/document-view/e2e.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,28 @@ describe('Document View', () => {
262262
})
263263
})
264264

265+
describe('breadcrumbs', () => {
266+
test('List drawer should not effect underlying breadcrumbs', async () => {
267+
await navigateToDoc(page, postsUrl)
268+
269+
expect(await page.locator('.step-nav.app-header__step-nav a').nth(1).innerText()).toBe(
270+
'Posts',
271+
)
272+
273+
await page.locator('#field-upload button.upload__listToggler').click()
274+
await expect(page.locator('[id^=list-drawer_1_]')).toBeVisible()
275+
await wait(100) // wait for the component to re-render
276+
277+
await expect(
278+
page.locator('.step-nav.app-header__step-nav .step-nav__last'),
279+
).not.toContainText('Uploads')
280+
281+
expect(await page.locator('.step-nav.app-header__step-nav a').nth(1).innerText()).toBe(
282+
'Posts',
283+
)
284+
})
285+
})
286+
265287
describe('custom document views', () => {
266288
test('collection — should render custom tab view', async () => {
267289
await page.goto(customViewsURL.create)

0 commit comments

Comments
 (0)