File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
packages/react-core/src/components/Card Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ export interface CardHeaderProps extends React.HTMLProps<HTMLDivElement> {
7575 toggleButtonProps ?: any ;
7676 /** Whether to right-align expandable toggle button */
7777 isToggleRightAligned ?: boolean ;
78+ /** Flag indicating that header wrapping is enabled */
79+ hasWrap ?: boolean ;
7880}
7981
8082export const CardHeader : React . FunctionComponent < CardHeaderProps > = ( {
@@ -86,6 +88,7 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
8688 onExpand,
8789 toggleButtonProps,
8890 isToggleRightAligned,
91+ hasWrap,
8992 ...props
9093} : CardHeaderProps ) => (
9194 < GenerateId >
@@ -177,7 +180,12 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
177180
178181 return (
179182 < div
180- className = { css ( styles . cardHeader , isToggleRightAligned && styles . modifiers . toggleRight , className ) }
183+ className = { css (
184+ styles . cardHeader ,
185+ isToggleRightAligned && styles . modifiers . toggleRight ,
186+ hasWrap && styles . modifiers . wrap ,
187+ className
188+ ) }
181189 id = { id }
182190 { ...props }
183191 >
Original file line number Diff line number Diff line change 11import { render , screen } from '@testing-library/react' ;
2+ import styles from '@patternfly/react-styles/css/components/Card/card' ;
3+ import '@testing-library/jest-dom' ;
24import userEvent from '@testing-library/user-event' ;
35import { CardHeader } from '../CardHeader' ;
46import { CardContext } from '../Card' ;
@@ -13,6 +15,18 @@ describe('CardHeader', () => {
1315 const { asFragment } = render ( < CardHeader actions = "test" /> ) ;
1416 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
1517 } ) ;
18+
19+ test ( `Should render CardHeader without ${ styles . modifiers . wrap } by default` , ( ) => {
20+ render ( < CardHeader data-testid = "card-header" /> ) ;
21+
22+ expect ( screen . getByTestId ( 'card-header' ) ) . not . toHaveClass ( styles . modifiers . wrap ) ;
23+ } ) ;
24+
25+ test ( `Should render CardHeader with ${ styles . modifiers . wrap } class when hasWrap is true` , ( ) => {
26+ render ( < CardHeader data-testid = "card-header-will-wrap" hasWrap /> ) ;
27+
28+ expect ( screen . getByTestId ( 'card-header-will-wrap' ) ) . toHaveClass ( styles . modifiers . wrap ) ;
29+ } ) ;
1630} ) ;
1731
1832// TODO: check if hasNoOffset for actions/selectableActions and className for selectableActions render
You can’t perform that action at this time.
0 commit comments