mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
Add control openKeys in Popup Menu
This commit is contained in:
parent
3c6c0d63a8
commit
3d3cc5f7a3
@ -13,13 +13,13 @@ const MenuItemGroup = Menu.ItemGroup;
|
||||
const App = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
current: 'mail'
|
||||
current: 'mail',
|
||||
};
|
||||
},
|
||||
handleClick(e) {
|
||||
console.log('click ', e);
|
||||
this.setState({
|
||||
current: e.key
|
||||
current: e.key,
|
||||
});
|
||||
},
|
||||
render() {
|
||||
|
@ -21,7 +21,7 @@ export default class Menu extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
openKeys: []
|
||||
openKeys: ('openKeys' in props) ? props.openKeys : [],
|
||||
};
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
@ -29,23 +29,28 @@ export default class Menu extends React.Component {
|
||||
nextProps.mode !== 'inline') {
|
||||
this.switchModeFromInline = true;
|
||||
}
|
||||
if ('openKeys' in nextProps) {
|
||||
this.setState({ openKeys: nextProps.openKeys });
|
||||
}
|
||||
}
|
||||
handleClick = (e) => {
|
||||
this.setState({
|
||||
openKeys: []
|
||||
openKeys: [],
|
||||
});
|
||||
this.props.onClick(e);
|
||||
}
|
||||
handleOpenKeys = (e) => {
|
||||
this.setState({
|
||||
openKeys: e.openKeys
|
||||
});
|
||||
const { openKeys } = e;
|
||||
if (!('openKeys' in this.props)) {
|
||||
this.setState({ openKeys });
|
||||
}
|
||||
this.props.onOpen(e);
|
||||
}
|
||||
handleCloseKeys = (e) => {
|
||||
this.setState({
|
||||
openKeys: e.openKeys
|
||||
});
|
||||
const { openKeys } = e;
|
||||
if (!('openKeys' in this.props)) {
|
||||
this.setState({ openKeys });
|
||||
}
|
||||
this.props.onClose(e);
|
||||
}
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user