fix(ui): selection status not updating after toggleAll in useSelection hook (#11218)

### What?

After clicking "Select all" `toggleAll(true)`, manually deselecting an
item does not update the overall selection status.

The bulk actions remain visible, and `selectAll` incorrectly stays as
`AllAvailable`.

### How?

Updated `setSelection()` logic to adjust `selectAll` when deselecting an
item if it was previously set to `AllAvailable`.

This ensures that the selection state updates correctly without altering
the effect logic.

`selectAll` switches to Some when an item is deselected after selecting
all.

Bulk actions now hide correctly if no items are selected.

Fixes #10836
This commit is contained in:
Patrik
2025-02-18 10:28:54 -05:00
committed by GitHub
parent 847d8d824f
commit 5817b81289
3 changed files with 19 additions and 7 deletions

View File

@@ -868,6 +868,20 @@ describe('General', () => {
await expect(page.locator('.row-1 .cell-title')).toContainText(updatedPostTitle)
})
test('should update selection state after deselecting item following select all', async () => {
await deleteAllPosts()
await createPost({ title: 'Post 1' })
await page.goto(postsUrl.list)
await page.locator('input#select-all').check()
await page.locator('button.list-selection__button').click()
// Deselect the first row
await page.locator('.row-1 input').click()
// eslint-disable-next-line jest-dom/prefer-checked
await expect(page.locator('input#select-all')).not.toHaveAttribute('checked', '')
})
test('should save globals', async () => {
await page.goto(postsUrl.global(globalSlug))

View File

@@ -64,7 +64,6 @@ export interface Config {
auth: {
users: UserAuthOperations;
};
blocks: {};
collections: {
uploads: Upload;
posts: Post;