Skip to content

Commit 788773e

Browse files
committed
allow aria-disabled pass-through in useButton
1 parent a3955f4 commit 788773e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/@react-aria/button/src/useButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<
114114
'aria-expanded': props['aria-expanded'],
115115
'aria-controls': props['aria-controls'],
116116
'aria-pressed': props['aria-pressed'],
117-
'aria-current': props['aria-current']
117+
'aria-current': props['aria-current'],
118+
'aria-disabled': props['aria-disabled']
118119
})
119120
};
120121
}

packages/@react-aria/button/test/useButton.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ describe('useButton tests', function () {
6161
expect(typeof result.current.buttonProps.onKeyDown).toBe('function');
6262
expect(result.current.buttonProps.rel).toBeUndefined();
6363
});
64+
65+
it('handles aria-disabled passthrough for button elements', function () {
66+
let props = {'aria-disabled': 'true'};
67+
let {result} = renderHook(() => useButton(props));
68+
expect(result.current.buttonProps['aria-disabled']).toBeTruthy();
69+
expect(result.current.buttonProps['disabled']).toBeUndefined();
70+
});
6471
});

0 commit comments

Comments
 (0)