Unverified Commit 9b13ab68 authored by 陈帅's avatar 陈帅 Committed by GitHub

bugfix:fix #3878, In the top mode. Menu will follow the slide (#3928)

* bugfix:fix #3878, In the top mode. Menu will follow the slide

* typo: repalce warp to wrap
parent 02cbcec9
...@@ -123,6 +123,17 @@ export default class BaseMenu extends PureComponent { ...@@ -123,6 +123,17 @@ export default class BaseMenu extends PureComponent {
return `/${path || ''}`.replace(/\/+/g, '/'); return `/${path || ''}`.replace(/\/+/g, '/');
}; };
getPopupContainer = (fixedHeader, layout) => {
if (fixedHeader && layout === 'topmenu') {
return this.wrap;
}
return document.body;
};
getRef = ref => {
this.wrap = ref;
};
render() { render() {
const { const {
openKeys, openKeys,
...@@ -131,6 +142,8 @@ export default class BaseMenu extends PureComponent { ...@@ -131,6 +142,8 @@ export default class BaseMenu extends PureComponent {
location: { pathname }, location: { pathname },
className, className,
collapsed, collapsed,
fixedHeader,
layout,
} = this.props; } = this.props;
// if pathname can't match, use the nearest parent's key // if pathname can't match, use the nearest parent's key
let selectedKeys = this.getSelectedMenuKeys(pathname); let selectedKeys = this.getSelectedMenuKeys(pathname);
...@@ -149,18 +162,22 @@ export default class BaseMenu extends PureComponent { ...@@ -149,18 +162,22 @@ export default class BaseMenu extends PureComponent {
}); });
return ( return (
<Menu <>
key="Menu" <Menu
mode={mode} key="Menu"
theme={theme} mode={mode}
onOpenChange={handleOpenChange} theme={theme}
selectedKeys={selectedKeys} onOpenChange={handleOpenChange}
style={style} selectedKeys={selectedKeys}
className={cls} style={style}
{...props} className={cls}
> {...props}
{this.getNavMenuItems(menuData)} getPopupContainer={() => this.getPopupContainer(fixedHeader, layout)}
</Menu> >
{this.getNavMenuItems(menuData)}
</Menu>
<div ref={this.getRef} />
</>
); );
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment