fix(next): disables active nav item (#11434)
When visiting a collection's list view, the nav item corresponding to that collection correctly appears in an active state, but is still rendered as an anchor tag. This makes it possible to reload the current page by simply clicking the link, which is a problem because this performs an unnecessary server roundtrip. This is especially apparent when search params exist in the current URL, as the href on the link does not. Unrelated: also cleans up leftover code that was missed in this PR: #11155
This commit is contained in:
@@ -11,7 +11,6 @@ import {
|
||||
ensureCompilationIsDone,
|
||||
exactText,
|
||||
initPageConsoleErrorCatch,
|
||||
openNav,
|
||||
saveDocAndAssert,
|
||||
} from '../../../helpers.js'
|
||||
import { AdminUrlUtil } from '../../../helpers/adminUrlUtil.js'
|
||||
@@ -46,6 +45,7 @@ const description = 'Description'
|
||||
let payload: PayloadTestSDK<Config>
|
||||
|
||||
import { navigateToDoc } from 'helpers/e2e/navigateToDoc.js'
|
||||
import { openNav } from 'helpers/e2e/toggleNav.js'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
exactText,
|
||||
getRoutes,
|
||||
initPageConsoleErrorCatch,
|
||||
openNav,
|
||||
saveDocAndAssert,
|
||||
saveDocHotkeyAndAssert,
|
||||
// throttleTest,
|
||||
@@ -51,6 +50,7 @@ let payload: PayloadTestSDK<Config>
|
||||
|
||||
import { navigateToDoc } from 'helpers/e2e/navigateToDoc.js'
|
||||
import { openDocControls } from 'helpers/e2e/openDocControls.js'
|
||||
import { openNav } from 'helpers/e2e/toggleNav.js'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
@@ -406,6 +406,15 @@ describe('General', () => {
|
||||
await expect(link).toBeHidden()
|
||||
})
|
||||
|
||||
test('should disable active nav item', async () => {
|
||||
await page.goto(postsUrl.list)
|
||||
await openNav(page)
|
||||
const activeItem = page.locator('.nav .nav__link.active')
|
||||
await expect(activeItem).toBeVisible()
|
||||
const tagName = await activeItem.evaluate((el) => el.tagName.toLowerCase())
|
||||
expect(tagName).toBe('div')
|
||||
})
|
||||
|
||||
test('breadcrumbs — should navigate from list to dashboard', async () => {
|
||||
await page.goto(postsUrl.list)
|
||||
await page.locator(`.step-nav a[href="${adminRoutes.routes.admin}"]`).click()
|
||||
|
||||
Reference in New Issue
Block a user