fix(ui): select all should reset when params change, page, filter, etc (#12612)

Fixes #11938
Fixes https://github.com/payloadcms/payload/issues/13154

When select-all is checked and you filter or change the page, the
selected documents should reset.
This commit is contained in:
Jarrod Flesch
2025-07-22 15:23:02 -04:00
committed by GitHub
parent 246a42b727
commit 412bf4ff73
2 changed files with 34 additions and 2 deletions

View File

@@ -1649,6 +1649,33 @@ describe('List View', () => {
'Custom placeholder',
)
})
test('should reset list selection when query params change', async () => {
await deleteAllPosts()
await Promise.all(Array.from({ length: 12 }, (_, i) => createPost({ title: `post${i + 1}` })))
await page.goto(postsUrl.list)
const pageOneButton = page.locator('.paginator__page', { hasText: '1' })
await expect(pageOneButton).toBeVisible()
await pageOneButton.click()
await page.locator('.checkbox-input:has(#select-all)').locator('input').click()
await expect(page.locator('.checkbox-input:has(#select-all)').locator('input')).toBeChecked()
await expect(page.locator('.list-selection')).toContainText('5 selected')
const pageTwoButton = page.locator('.paginator__page', { hasText: '2' })
await expect(pageTwoButton).toBeVisible()
await pageTwoButton.click()
await expect(
page.locator('.checkbox-input:has(#select-all) input:not([checked])'),
).toBeVisible()
await page.locator('.row-1 .cell-_select input').check()
await page.locator('.row-2 .cell-_select input').check()
await expect(page.locator('.list-selection')).toContainText('2 selected')
})
})
async function createPost(overrides?: Partial<Post>): Promise<Post> {