fix: menu cannot get refs.innerMenu

pull/2682/head
tanjinzhou 2020-07-15 18:22:32 +08:00
parent 41e3630f8d
commit d530e65f3c
1 changed files with 5 additions and 2 deletions

View File

@ -72,7 +72,7 @@ const Menu = {
// e.g., in rc-select, we need to navigate menu item while // e.g., in rc-select, we need to navigate menu item while
// current active item is rc-select input box rather than the menu itself // current active item is rc-select input box rather than the menu itself
onKeyDown(e, callback) { onKeyDown(e, callback) {
this.$refs.innerMenu.getWrappedInstance().onKeyDown(e, callback); this.innerMenu.getWrappedInstance().onKeyDown(e, callback);
}, },
onOpenChange(event) { onOpenChange(event) {
const openKeys = this.store.getState().openKeys.concat(); const openKeys = this.store.getState().openKeys.concat();
@ -150,6 +150,9 @@ const Menu = {
}); });
} }
}, },
saveInnerMenu(ref) {
this.innerMenu = ref;
},
}, },
render() { render() {
@ -169,7 +172,7 @@ const Menu = {
onOpenChange: this.onOpenChange, onOpenChange: this.onOpenChange,
onDeselect: this.onDeselect, onDeselect: this.onDeselect,
onSelect: this.onSelect, onSelect: this.onSelect,
ref: 'innerMenu', ref: this.saveInnerMenu,
}; };
const subPopupMenu = <SubPopupMenu {...subPopupMenuProps} />; const subPopupMenu = <SubPopupMenu {...subPopupMenuProps} />;