Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/ui/src/providers/ListQuery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const ListQueryProvider: React.FC<ListQueryProps> = ({
if (modifySearchParams) {
const search = `?${qs.stringify({
...newQuery,
columns: JSON.stringify(newQuery.columns),
columns:
typeof newQuery.columns === 'string'
? newQuery.columns
: JSON.stringify(newQuery.columns),
queryByGroup: JSON.stringify(newQuery.queryByGroup),
})}`
if (window.location.search !== search) {
Expand Down
21 changes: 21 additions & 0 deletions test/admin/e2e/list-view/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,27 @@ describe('List View', () => {
await expect(page.locator('table > thead > tr > th:nth-child(2)')).toHaveText('Number')
})

test('should retain column visibility after reload and navigating to the next page', async () => {
await deleteAllPosts()

await mapAsync([...Array(6)], async () => {
await createPost()
})

await page.goto(postsUrl.list)
await setPerPageLimit({ page, limit: 5 })

await toggleColumn(page, { columnLabel: 'ID', columnName: 'id', targetState: 'off' })

await page.reload()

await expect(page.locator('#heading-id')).toBeHidden()

await goToNextPage(page)

await expect(page.locator('#heading-id')).toBeHidden()
})

test('should inject preferred columns into URL search params on load', async () => {
await toggleColumn(page, { columnLabel: 'ID', columnName: 'id', targetState: 'off' })

Expand Down
Loading