Skip to content

Commit ba727bd

Browse files
authored
fix: table select-all error when triggered twice with keyboard shortcut (#4415)
* fix(stately-selection): add keys match condition * feat(aria-selection): add support for toggle state * test(spectrum-table): double check selecting all via ctrl + A * chore(aria-selection): rollback to select-all
1 parent 0e060e1 commit ba727bd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/@react-spectrum/table/test/Table.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,13 @@ describe('TableView', function () {
23472347
expect(onSelectionChange.mock.calls[0][0]).toEqual('all');
23482348
checkRowSelection(rows.slice(1), true);
23492349
checkSelectAll(tree, 'checked');
2350+
2351+
fireEvent.keyDown(getCell(tree, 'Bar 1'), {key: 'a', ctrlKey: true});
2352+
2353+
expect(onSelectionChange).toHaveBeenCalledTimes(1);
2354+
expect(onSelectionChange.mock.calls[0][0]).toEqual('all');
2355+
checkRowSelection(rows.slice(1), true);
2356+
checkSelectAll(tree, 'checked');
23502357
});
23512358

23522359
it('should deselect an item after selecting all', function () {

packages/@react-stately/selection/src/SelectionManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class SelectionManager implements MultipleSelectionManager {
402402
* Selects all items in the collection.
403403
*/
404404
selectAll() {
405-
if (this.selectionMode === 'multiple') {
405+
if (!this.isSelectAll && this.selectionMode === 'multiple') {
406406
this.state.setSelectedKeys('all');
407407
}
408408
}

0 commit comments

Comments
 (0)