Skip to content

Commit

Permalink
feat: _internalRenderSubMenuItem and _internalRenderMenuItem support …
Browse files Browse the repository at this point in the history
…selected (#432)

* _internalRenderSubMenuItem and _internalRenderMenuItem support selected

* use stateProps

Co-authored-by: 期贤 <qixian.cs@antgroup.com>
  • Loading branch information
chenshuai2144 and chenshuai2144 authored Jan 17, 2022
1 parent d6b1eb0 commit 0256d8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export interface MenuProps
_internalRenderMenuItem?: (
originNode: React.ReactElement,
menuItemProps: any,
stateProps: {
selected: boolean;
},
) => React.ReactElement;
/***
* @private Only used for `pro-layout`. Do not use in your prod directly
Expand All @@ -128,6 +131,9 @@ export interface MenuProps
_internalRenderSubMenuItem?: (
originNode: React.ReactElement,
subMenuItemProps: any,
stateProps: {
selected: boolean;
},
) => React.ReactElement;
}

Expand Down
2 changes: 1 addition & 1 deletion src/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const InternalMenuItem = (props: MenuItemProps) => {
);

if (_internalRenderMenuItem) {
renderNode = _internalRenderMenuItem(renderNode, props);
renderNode = _internalRenderMenuItem(renderNode, props, { selected });
}

return renderNode;
Expand Down
4 changes: 3 additions & 1 deletion src/SubMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ const InternalSubMenu = (props: SubMenuProps) => {
);

if (_internalRenderSubMenuItem) {
listNode = _internalRenderSubMenuItem(listNode, props);
listNode = _internalRenderSubMenuItem(listNode, props, {
selected: childrenSelected,
});
}

// >>>>> Render
Expand Down

0 comments on commit 0256d8b

Please sign in to comment.