Skip to content

Commit

Permalink
fix: should not throw error when keydown in menu, close: ant-design#8089
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui authored and afc163 committed Nov 16, 2017
1 parent fce6862 commit 06a1b6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class MenuItem extends React.Component<any, any> {
inlineCollapsed: PropTypes.bool,
};
static isMenuItem = 1;
private menuItem: any;
onKeyDown = (e) => {
this.menuItem.onKeyDown(e);
}
saveMenuItem = (menuItem) => {
this.menuItem = menuItem;
}
render() {
const { inlineCollapsed } = this.context;
const props = this.props;
Expand All @@ -16,7 +23,7 @@ class MenuItem extends React.Component<any, any> {
placement="right"
overlayClassName={`${props.rootPrefixCls}-inline-collapsed-tooltip`}
>
<Item {...props} />
<Item {...props} ref={this.saveMenuItem} />
</Tooltip>;
}
}
Expand Down
8 changes: 8 additions & 0 deletions components/menu/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ class SubMenu extends React.Component<any, any> {
static contextTypes = {
antdMenuTheme: PropTypes.string,
};
private subMenu: any;
onKeyDown = (e) => {
this.subMenu.onKeyDown(e);
}
saveSubMenu = (subMenu) => {
this.subMenu = subMenu;
}
render() {
const { rootPrefixCls, className } = this.props;
const theme = this.context.antdMenuTheme;
return (
<RcSubMenu
{...this.props}
ref={this.saveSubMenu}
popupClassName={classNames(`${rootPrefixCls}-${theme}`, className)}
/>
);
Expand Down

0 comments on commit 06a1b6e

Please sign in to comment.