Skip to content

Commit b74d8b8

Browse files
rohit-bharmalRohit Bharmal
andauthored
fix(MenuGroup): fix title generation when the string is empty (#11999)
Co-authored-by: Rohit Bharmal <rbharmal@redhat.com>
1 parent eed7e65 commit b74d8b8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

packages/react-core/src/components/Menu/MenuGroup.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,28 @@ export interface MenuGroupProps extends Omit<React.HTMLProps<HTMLElement>, 'labe
2020
const MenuGroupBase: React.FunctionComponent<MenuGroupProps> = ({
2121
children,
2222
className = '',
23-
label = '',
23+
label,
2424
titleId,
2525
innerRef,
2626
labelHeadingLevel: HeadingLevel = 'h1',
2727
...props
2828
}: MenuGroupProps) => {
2929
const Wrapper = typeof label === 'function' ? label : HeadingLevel;
30+
const hasLabel = label !== undefined && label !== null && label !== '';
31+
3032
return (
3133
<section {...props} className={css(styles.menuGroup, className)} ref={innerRef}>
3234
<>
33-
{['function', 'string'].includes(typeof label) ? (
34-
<Wrapper className={css(styles.menuGroupTitle)} id={titleId}>
35-
{label}
36-
</Wrapper>
37-
) : (
38-
label
35+
{hasLabel && (
36+
<>
37+
{['function', 'string'].includes(typeof label) ? (
38+
<Wrapper className={css(styles.menuGroupTitle)} id={titleId}>
39+
{label}
40+
</Wrapper>
41+
) : (
42+
label
43+
)}
44+
</>
3945
)}
4046
{children}
4147
</>

0 commit comments

Comments
 (0)