2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2018-08-07 21:07:52 +08:00
|
|
|
import * as PropTypes from 'prop-types';
|
2017-11-11 00:07:03 +08:00
|
|
|
import { SubMenu as RcSubMenu } from 'rc-menu';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
class SubMenu extends React.Component<any, any> {
|
|
|
|
static contextTypes = {
|
|
|
|
antdMenuTheme: PropTypes.string,
|
|
|
|
};
|
2018-06-01 18:09:11 +08:00
|
|
|
// fix issue:https://github.com/ant-design/ant-design/issues/8666
|
|
|
|
static isSubMenu = 1;
|
2018-11-09 17:38:19 +08:00
|
|
|
context: any;
|
2017-11-16 16:08:30 +08:00
|
|
|
private subMenu: any;
|
2018-12-13 22:03:12 +08:00
|
|
|
|
2017-11-21 17:38:51 +08:00
|
|
|
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.subMenu.onKeyDown(e);
|
2018-12-07 20:02:01 +08:00
|
|
|
};
|
2017-11-21 17:38:51 +08:00
|
|
|
saveSubMenu = (subMenu: any) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.subMenu = subMenu;
|
2018-12-07 20:02:01 +08:00
|
|
|
};
|
2017-11-11 00:07:03 +08:00
|
|
|
render() {
|
|
|
|
const { rootPrefixCls, className } = this.props;
|
|
|
|
const theme = this.context.antdMenuTheme;
|
|
|
|
return (
|
|
|
|
<RcSubMenu
|
|
|
|
{...this.props}
|
2017-11-16 16:08:30 +08:00
|
|
|
ref={this.saveSubMenu}
|
2017-11-11 00:07:03 +08:00
|
|
|
popupClassName={classNames(`${rootPrefixCls}-${theme}`, className)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SubMenu;
|