fix(ui): refreshes column state during hmr and respects admin.disableListColumn despite preferences (#9846)
Partial fix for #9774. When `admin.disableListColumn` is set retroactively, it continues to appear in column state, but shouldn't. This was because the table column context was not refreshing after HMR runs, and would instead hold onto these stale columns until the page itself refreshes. Similarly, this was also a problem when the user had saved any of these columns to their list preferences, where those prefs would take precedence despite these properties being set on the underlying fields. The fix is to filter these columns from all requests that send them, and ensure local component state properly refreshes itself.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import type { Page } from '@playwright/test'
|
||||
import type { GeneratedTypes } from 'helpers/sdk/types.js'
|
||||
|
||||
import { expect, test } from '@playwright/test'
|
||||
import { openListColumns, toggleColumn } from 'helpers/e2e/toggleColumn.js'
|
||||
import { upsertPrefs } from 'helpers/e2e/upsertPrefs.js'
|
||||
import path from 'path'
|
||||
import { wait } from 'payload/shared'
|
||||
import { fileURLToPath } from 'url'
|
||||
@@ -203,6 +205,32 @@ describe('Text', () => {
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('should respect admin.disableListColumn despite preferences', async () => {
|
||||
await upsertPrefs<Config, GeneratedTypes<any>>({
|
||||
payload,
|
||||
user: client.user,
|
||||
value: {
|
||||
columns: [
|
||||
{
|
||||
accessor: 'disableListColumnText',
|
||||
active: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
await page.goto(url.list)
|
||||
await openListColumns(page, {})
|
||||
await expect(
|
||||
page.locator(`.column-selector .column-selector__column`, {
|
||||
hasText: exactText('Disable List Column Text'),
|
||||
}),
|
||||
).toBeHidden()
|
||||
|
||||
await expect(page.locator('#heading-disableListColumnText')).toBeHidden()
|
||||
await expect(page.locator('table .row-1 .cell-disableListColumnText')).toBeHidden()
|
||||
})
|
||||
|
||||
test('should hide field in filter when admin.disableListFilter is true', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
|
||||
@@ -156,14 +156,12 @@ const TextFields: CollectionConfig = {
|
||||
type: 'text',
|
||||
admin: {
|
||||
disableListColumn: true,
|
||||
disableListFilter: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'disableListFilterText',
|
||||
type: 'text',
|
||||
admin: {
|
||||
disableListColumn: false,
|
||||
disableListFilter: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user