File tree Expand file tree Collapse file tree
packages/react-core/src/components/Drawer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import styles from '@patternfly/react-styles/css/components/Drawer/drawer' ;
22import { css } from '@patternfly/react-styles' ;
3- import { Button } from '../Button' ;
3+ import { Button , ButtonProps } from '../Button' ;
44import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon' ;
55
66export 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
1517export 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) ;
2528DrawerCloseButton . displayName = 'DrawerCloseButton' ;
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments