Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4c022d3
fix(#7372): trigger onAction on Space key when selectionMode is none
jsmitrah Jul 29, 2026
498f88a
Fixed lint error.
jsmitrah Jul 29, 2026
b7b7059
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Jul 30, 2026
a3ecc05
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Jul 31, 2026
43579c0
Trigger CircleCI
jsmitrah Jul 31, 2026
4d21256
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 3, 2026
2cbde13
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 4, 2026
46a009b
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 7, 2026
744aae1
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 10, 2026
b9a9d9b
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 11, 2026
5f202ff
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 12, 2026
1047fcd
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 13, 2026
ab7749d
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 14, 2026
6ad2960
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 17, 2026
25402ec
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 18, 2026
bb6c09d
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 19, 2026
17ef1fd
Merge branch 'main' into fix/7372/tree-space-onAction-selection-none
jsmitrah Aug 20, 2026
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
24 changes: 24 additions & 0 deletions packages/react-aria-components/test/Tree.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,30 @@ describe('Tree', () => {
expect(rows).toHaveLength(17);
});

it('should expand/collapse a row when using Space on the row when selectionMode is none', async () => {
if (type !== 'keyboard') {
return;
}

let {getAllByRole} = render(<DynamicTree />);
let rows = getAllByRole('row');
expect(rows).toHaveLength(20);

await user.tab();
expect(document.activeElement).toBe(rows[0]);
expect(rows[0]).toHaveAttribute('data-expanded', 'true');

await user.keyboard(' ');
expect(document.activeElement).toBe(rows[0]);
expect(rows[0]).not.toHaveAttribute('data-expanded');
expect(onExpandedChange).toHaveBeenCalledTimes(1);

await user.keyboard(' ');
expect(document.activeElement).toBe(rows[0]);
expect(rows[0]).toHaveAttribute('data-expanded', 'true');
expect(onExpandedChange).toHaveBeenCalledTimes(2);
});

it('should not expand when clicking/using Enter on the row if the row is selectable', async () => {
let {getAllByRole} = render(<DynamicTree treeProps={{selectionMode: 'multiple'}} />);
let rows = getAllByRole('row');
Expand Down
10 changes: 8 additions & 2 deletions packages/react-aria/src/selection/useSelectableItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
// oxlint-disable-next-line react/react-compiler
itemPressProps.onPress = e => {
if (hasPrimaryAction || (hasSecondaryAction && e.pointerType !== 'mouse')) {
if (e.pointerType === 'keyboard' && !isActionKey(e.key)) {
if (
e.pointerType === 'keyboard' &&
!isActionKey(e.key) &&
!(!allowsSelection && isSelectionKey(e.key))
) {
return;
}

Expand Down Expand Up @@ -353,7 +357,9 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
e.pointerType === 'touch' ||
e.pointerType === 'pen' ||
e.pointerType === 'virtual' ||
(e.pointerType === 'keyboard' && hasAction && isActionKey(e.key)) ||
(e.pointerType === 'keyboard' &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading the comment about this:

Both primary and secondary actions occur on Enter key up

It seems like it might have been intentional we only did Enter, not Space. Will see if anyone recalls.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing this. I'll wait until someone who remembers the original intent can provide more context.

hasAction &&
(isActionKey(e.key) || (!allowsSelection && isSelectionKey(e.key)))) ||
(e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current)
) {
if (hasAction) {
Expand Down