fix(ui): ensures admin.disableListFilter is disabled despite url search params (#9874)

Continuation of #9846 and partial fix for #9774. When setting
`admin.disableListFilter` retroactively, it remains active within the
list filter controls. Same for when the URL search query contains one of
these fields, except this will actually display the _wrong_ field,
falling back to the _first_ field from the config. The fix is to
properly disable the condition for this field if it's an active filter,
while still preventing it from ever rendering as an option within the
field selector itself.
This commit is contained in:
Jacob Fletcher
2024-12-10 17:37:52 -05:00
committed by GitHub
parent f7172b5b2c
commit da6bc55b19
12 changed files with 147 additions and 66 deletions

View File

@@ -26,8 +26,10 @@ const description = 'Description'
let payload: PayloadTestSDK<Config>
import { goToFirstCell, navigateToDoc } from 'helpers/e2e/navigateToDoc.js'
import { openListColumns, toggleColumn } from 'helpers/e2e/toggleColumn.js'
import { goToFirstCell } from 'helpers/e2e/navigateToDoc.js'
import { openListColumns } from 'helpers/e2e/openListColumns.js'
import { openListFilters } from 'helpers/e2e/openListFilters.js'
import { toggleColumn } from 'helpers/e2e/toggleColumn.js'
import path from 'path'
import { wait } from 'payload/shared'
import { fileURLToPath } from 'url'
@@ -273,9 +275,7 @@ describe('admin2', () => {
await expect(page.locator(tableRowLocator)).toHaveCount(2)
await page.locator('.list-controls__toggle-where').click()
// wait until the filter UI is visible and fully expanded
await expect(page.locator('.list-controls__where.rah-static--height-auto')).toBeVisible()
await openListFilters(page, {})
await page.locator('.where-builder__add-first-filter').click()
@@ -313,8 +313,7 @@ describe('admin2', () => {
// open the column controls
await page.locator('.list-controls__toggle-columns').click()
await page.locator('.list-controls__toggle-where').click()
await page.waitForSelector('.list-controls__where.rah-static--height-auto')
await openListFilters(page, {})
await page.locator('.where-builder__add-first-filter').click()
const operatorField = page.locator('.condition__operator')
@@ -461,7 +460,7 @@ describe('admin2', () => {
await page.goto(`${postsUrl.list}?limit=10&page=2`)
// add filter
await page.locator('.list-controls__toggle-where').click()
await openListFilters(page, {})
await page.locator('.where-builder__add-first-filter').click()
await page.locator('.condition__field .rs__control').click()
const options = page.locator('.rs__option')
@@ -776,7 +775,7 @@ describe('admin2', () => {
).toHaveText('Title')
// filters
await page.locator('.list-controls__toggle-where').click()
await openListFilters(page, {})
await page.locator('.where-builder__add-first-filter').click()
await page.locator('.condition__field .rs__control').click()
const options = page.locator('.rs__option')