From 4c022d3ef367a698dfb479da9cd144941c57783d Mon Sep 17 00:00:00 2001 From: Jsmitrah Date: Wed, 29 Jul 2026 13:50:07 +0000 Subject: [PATCH 1/3] fix(#7372): trigger onAction on Space key when selectionMode is none --- .../react-aria-components/test/Tree.test.tsx | 24 +++++++++++++++++++ .../src/selection/useSelectableItem.ts | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/react-aria-components/test/Tree.test.tsx b/packages/react-aria-components/test/Tree.test.tsx index c0087e78fd9..f56a0df175e 100644 --- a/packages/react-aria-components/test/Tree.test.tsx +++ b/packages/react-aria-components/test/Tree.test.tsx @@ -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(); + 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(); let rows = getAllByRole('row'); diff --git a/packages/react-aria/src/selection/useSelectableItem.ts b/packages/react-aria/src/selection/useSelectableItem.ts index b45620fc071..1f097ac72b5 100644 --- a/packages/react-aria/src/selection/useSelectableItem.ts +++ b/packages/react-aria/src/selection/useSelectableItem.ts @@ -297,7 +297,7 @@ 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; } @@ -353,7 +353,7 @@ 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' && hasAction && (isActionKey(e.key) || (!allowsSelection && isSelectionKey(e.key)))) || (e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) ) { if (hasAction) { From 498f88abbd3bce33205b5ae142ed934a3fdc012d Mon Sep 17 00:00:00 2001 From: Jsmitrah Date: Wed, 29 Jul 2026 14:07:03 +0000 Subject: [PATCH 2/3] Fixed lint error. --- packages/react-aria/src/selection/useSelectableItem.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-aria/src/selection/useSelectableItem.ts b/packages/react-aria/src/selection/useSelectableItem.ts index 1f097ac72b5..b8e2e3c3815 100644 --- a/packages/react-aria/src/selection/useSelectableItem.ts +++ b/packages/react-aria/src/selection/useSelectableItem.ts @@ -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) && !(!allowsSelection && isSelectionKey(e.key))) { + if ( + e.pointerType === 'keyboard' && + !isActionKey(e.key) && + !(!allowsSelection && isSelectionKey(e.key)) + ) { return; } @@ -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) || (!allowsSelection && isSelectionKey(e.key)))) || + (e.pointerType === 'keyboard' && + hasAction && + (isActionKey(e.key) || (!allowsSelection && isSelectionKey(e.key)))) || (e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) ) { if (hasAction) { From 43579c00e69f77a706867e3340df3fa1b11f3dc7 Mon Sep 17 00:00:00 2001 From: Jsmitrah Date: Fri, 31 Jul 2026 06:36:16 +0000 Subject: [PATCH 3/3] Trigger CircleCI