Browse Source

hide submenu on click

pull/504/head
afc163 9 years ago
parent
commit
f2ce959d33
  1. 39
      components/menu/index.jsx

39
components/menu/index.jsx

@ -2,12 +2,41 @@ import React from 'react';
import Menu from 'rc-menu';
import animation from '../common/openAnimation';
function noop() {
}
const AntMenu = React.createClass({
getDefaultProps() {
return {
prefixCls: 'ant-menu'
prefixCls: 'ant-menu',
onClick: noop,
onOpen: noop,
onClose: noop,
};
},
getInitialState() {
return {
openKeys: []
};
},
handleClick() {
this.setState({
openKeys: []
});
this.props.onClick();
},
handleOpenKeys(e) {
this.setState({
openKeys: e.openKeys
});
this.props.onOpen();
},
handleCloseKeys(e) {
this.setState({
openKeys: e.openKeys
});
this.props.onClose();
},
render() {
let openAnimation = '';
switch (this.props.mode) {
@ -22,10 +51,16 @@ const AntMenu = React.createClass({
break;
default:
}
let props = {
openKeys: this.state.openKeys,
onClick: this.handleClick,
onOpen: this.handleOpenKeys,
onClose: this.handleCloseKeys,
};
if (this.props.mode === 'inline') {
return <Menu {...this.props} openAnimation={openAnimation} />;
} else {
return <Menu {...this.props} openTransitionName={openAnimation} />;
return <Menu {...this.props} {...props} openTransitionName={openAnimation} />;
}
}
});

Loading…
Cancel
Save