Skip to content

Commit 383ccf5

Browse files
committed
fix(menu): only pass overlayClassName to SubMenu children
Menu was passing overlayClassName to all children via cloneElement, but only SubMenu uses it. MenuItem and MenuItemGroup spread otherProps onto <li>, leaking the unrecognized prop to the DOM.
1 parent d3d550c commit 383ccf5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

components/menu/menu.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ const Menu = (props: MenuProps): JSX.Element => {
5151
displayName === 'MenuItemGroup' ||
5252
(displayName === 'MenuDivider' && mode !== 'horizontal')
5353
) {
54-
const childProps = {
55-
overlayClassName,
56-
index: `${index}`,
57-
};
54+
const childProps = displayName === 'SubMenu' && overlayClassName
55+
? { index: `${index}`, overlayClassName }
56+
: { index: `${index}` };
5857
return React.cloneElement(childElement, childProps);
5958
} else {
6059
console.warn('Menu has a child that is not a MenuItem component.');

0 commit comments

Comments
 (0)