Skip to content

Commit 0df3071

Browse files
authored
ActionGroup item custom props support (#3279)
1 parent 0b1c23e commit 0df3071

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/@react-spectrum/actiongroup/src/ActionGroup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ function ActionGroupItem<T>({item, state, isDisabled, isEmphasized, staticColor,
271271
isDisabled = isDisabled || state.disabledKeys.has(item.key);
272272
let isSelected = state.selectionManager.isSelected(item.key);
273273
let {hoverProps, isHovered} = useHover({isDisabled});
274+
let domProps = filterDOMProps(item.props);
274275

275276
if (onAction && !isDisabled) {
276277
buttonProps = mergeProps(buttonProps, {
@@ -291,7 +292,7 @@ function ActionGroupItem<T>({item, state, isDisabled, isEmphasized, staticColor,
291292
let button = (
292293
// Use a PressResponder to send DOM props through.
293294
// ActionButton doesn't allow overriding the role by default.
294-
<PressResponder {...mergeProps(buttonProps, hoverProps)}>
295+
<PressResponder {...mergeProps(buttonProps, hoverProps, domProps)}>
295296
<ClearSlots>
296297
<SlotProvider
297298
slots={{

packages/@react-spectrum/actiongroup/test/ActionGroup.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,19 @@ describe('ActionGroup', function () {
513513
expect(button1).toHaveAttribute('data-testid', 'test');
514514
});
515515

516+
it('ActionGroup Item allows custom props', function () {
517+
let {getAllByRole} = render(
518+
<Provider theme={theme} locale="de-DE">
519+
<ActionGroup>
520+
<Item data-testid="test">Click me</Item>
521+
</ActionGroup>
522+
</Provider>
523+
);
524+
525+
let item = getAllByRole('button')[0];
526+
expect(item).toHaveAttribute('data-testid', 'test');
527+
});
528+
516529
it('fires onAction when a button is pressed', function () {
517530
let onAction = jest.fn();
518531
let tree = render(

0 commit comments

Comments
 (0)