Skip to content

Commit df9b0a0

Browse files
committed
fix(DrawerCloseButton): Allow props spread to button
Props were previously only spread to parent div. This allows for props spread to button. Enables patternfly/chatbot#834
1 parent 4d61988 commit df9b0a0

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
22
import { css } from '@patternfly/react-styles';
3-
import { Button } from '../Button';
3+
import { Button, ButtonProps } from '../Button';
44
import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon';
55

66
export interface DrawerCloseButtonProps extends React.HTMLProps<HTMLDivElement> {
@@ -10,16 +10,19 @@ export interface DrawerCloseButtonProps extends React.HTMLProps<HTMLDivElement>
1010
onClose?: () => void;
1111
/** Accessible label for the drawer close button */
1212
'aria-label'?: string;
13+
/** Additional properties spread to the close button */
14+
buttonProps?: ButtonProps;
1315
}
1416

1517
export const DrawerCloseButton: React.FunctionComponent<DrawerCloseButtonProps> = ({
1618
className = '',
1719
onClose = () => undefined as any,
1820
'aria-label': ariaLabel = 'Close drawer panel',
21+
buttonProps,
1922
...props
2023
}: DrawerCloseButtonProps) => (
2124
<div className={css(styles.drawerClose, className)} {...props}>
22-
<Button variant="plain" onClick={onClose} aria-label={ariaLabel} icon={<RhMicronsCloseIcon />} />
25+
<Button variant="plain" onClick={onClose} aria-label={ariaLabel} icon={<RhMicronsCloseIcon />} {...buttonProps} />
2326
</div>
2427
);
2528
DrawerCloseButton.displayName = 'DrawerCloseButton';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { DrawerCloseButton } from '../DrawerCloseButton';
3+
4+
test('Renders with spread buttonProps', () => {
5+
render(<DrawerCloseButton buttonProps={{ isDisabled: true }} />);
6+
expect(screen.getByRole('button')).toHaveAttribute('disabled');
7+
});

0 commit comments

Comments
 (0)