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 {
return `/${path || ''}`.replace(/\/+/g, '/');
};
getPopupContainer = (fixedHeader, layout) => {
if (fixedHeader && layout === 'topmenu') {
return this.wrap;
}
return document.body;
};
getRef = ref => {
this.wrap = ref;
};
render() {
const {
openKeys,
......@@ -131,6 +142,8 @@ export default class BaseMenu extends PureComponent {
location: { pathname },
className,
collapsed,
fixedHeader,
layout,
} = this.props;
// if pathname can't match, use the nearest parent's key
let selectedKeys = this.getSelectedMenuKeys(pathname);
......@@ -149,6 +162,7 @@ export default class BaseMenu extends PureComponent {
});
return (
<>
<Menu
key="Menu"
mode={mode}
......@@ -158,9 +172,12 @@ export default class BaseMenu extends PureComponent {
style={style}
className={cls}
{...props}
getPopupContainer={() => this.getPopupContainer(fixedHeader, layout)}
>
{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