Skip to content

Commit

Permalink
fix(Menu): Fix Menu defaultOpened fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 8, 2018
1 parent 997f7e0 commit f49af35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default class Menu extends Component {
// 点击子菜单的标题事件
handleSubmenuClick(index) {
const isOpened = this.state.openedMenu.indexOf(index) !== -1;

if (isOpened) {
this.closeMenu(index);
if (this.props.onClose) {
Expand Down Expand Up @@ -92,13 +91,15 @@ Menu.propTypes = {
mode: PropTypes.oneOf(['vertical', 'inline', 'horizontal']),
theme: PropTypes.oneOf(['light', 'dark']),
defaultActive: PropTypes.string,
defaultOpened: PropTypes.array,
inlineCollapsed: PropTypes.bool,
onSelect: PropTypes.func,
};

Menu.defaultProps = {
prefixCls: 'w-menu',
mode: 'vertical',
defaultOpened: [],
inlineCollapsed: false,
theme: 'light',
};
2 changes: 1 addition & 1 deletion src/menu/SubMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class SubMenu extends MixinComponent {
componentWillReceiveProps() {
if (this.state.mode !== this.menu().props.mode) {
this.unMountEvents();
this.menu().closeMenu(this.props.index);
this.setState({
mode: this.menu().props.mode,
});
Expand All @@ -64,7 +65,6 @@ export default class SubMenu extends MixinComponent {
}
initEvents() {
// 切换 mode 弹出的浮层隐藏
this.menu().closeMenu(this.props.index);
// horizontal(水平) 和 vertical(垂直) 和 inline
if (this.menu().props.mode === 'vertical') {
this.submenu.addEventListener('click', this.handleClick);
Expand Down

0 comments on commit f49af35

Please sign in to comment.