Skip to content

Commit 1365cdb

Browse files
authored
Fix buttons inside disabled grid list items not being disabled (#6324)
Fix buttons inside disabled grid list items not being disabled (#6324)
1 parent c348867 commit 1365cdb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/react-aria-components/src/GridList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ function GridListRow({item}) {
275275
state
276276
);
277277

278+
let buttonProps = state.selectionManager.disabledBehavior === 'all' && states.isDisabled ? {isDisabled: true} : {};
279+
278280
let draggableItem: DraggableItemResult | null = null;
279281
if (dragState && dragAndDropHooks) {
280282
draggableItem = dragAndDropHooks.useDraggableItem!({key: item.key, hasDragButton: true}, dragState);
@@ -359,7 +361,7 @@ function GridListRow({item}) {
359361
}],
360362
[ButtonContext, {
361363
slots: {
362-
[DEFAULT_SLOT]: {},
364+
[DEFAULT_SLOT]: buttonProps,
363365
drag: {
364366
...draggableItem?.dragButtonProps,
365367
ref: dragButtonRef,

packages/react-aria-components/test/GridList.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,13 @@ describe('GridList', () => {
231231
let {getAllByRole} = render(
232232
<GridList aria-label="Test">
233233
<GridListItem id="cat">Cat</GridListItem>
234-
<GridListItem id="dog" isDisabled>Dog</GridListItem>
234+
<GridListItem id="dog" textValue="Dog" isDisabled>Dog <Button aria-label="Info"></Button></GridListItem>
235235
<GridListItem id="kangaroo">Kangaroo</GridListItem>
236236
</GridList>
237237
);
238238
let items = getAllByRole('row');
239239
expect(items[1]).toHaveAttribute('aria-disabled', 'true');
240+
expect(within(items[1]).getByRole('button')).toBeDisabled();
240241

241242
await user.tab();
242243
expect(document.activeElement).toBe(items[0]);

0 commit comments

Comments
 (0)