Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
picodoth committed Apr 19, 2018
1 parent f64f09f commit e1d27b9
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 99 deletions.
3 changes: 1 addition & 2 deletions examples/selectedKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class Test extends React.Component {
<div style={{ width: 400 }}>{this.getMenu()}</div>
</div>);
}
};

}

ReactDOM.render(<Test />, document.getElementById('__react-content'));
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"dependencies": {
"babel-runtime": "6.x",
"classnames": "2.x",
"create-react-class": "^15.5.2",
"dom-scroll-into-view": "1.x",
"mini-store": "^1.1.0",
"prop-types": "^15.5.6",
Expand Down
8 changes: 4 additions & 4 deletions src/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class Menu extends React.Component {
}

render() {
let { children, ...props } = this.props;
let { ...props } = this.props;
props.className += ` ${props.prefixCls}-root`;
props = {
...props,
Expand All @@ -194,11 +194,11 @@ export default class Menu extends React.Component {
onSelect: this.onSelect,
openTransitionName: this.getOpenTransitionName(),
parentMenu: this,
}
};
return (
<Provider store={this.store}>
<SubPopupMenu {...props} ref={c => this.innerMenu = c}>{children}</SubPopupMenu>
<SubPopupMenu {...props} ref={c => this.innerMenu = c}>{this.props.children}</SubPopupMenu>
</Provider>
);
}
};
}
18 changes: 11 additions & 7 deletions src/MenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,20 @@ export class MenuItem extends React.Component {
onDestroy: PropTypes.func,
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
multiple: PropTypes.bool,
isSelected: PropTypes.bool,
manualRef: PropTypes.func,
};

static defaultProps = {
onSelect: noop,
onMouseEnter: noop,
onMouseLeave: noop,
manualRef: noop,
};

constructor(props) {
super(props);
}

componentWillUnmount() {
const props = this.props;
if (props.onDestroy) {
props.onDestroy(props.eventKey);
}
}

componentDidMount() {
Expand All @@ -60,6 +57,13 @@ export class MenuItem extends React.Component {
this.callRef();
}

componentWillUnmount() {
const props = this.props;
if (props.onDestroy) {
props.onDestroy(props.eventKey);
}
}

onKeyDown = (e) => {
const keyCode = e.keyCode;
if (keyCode === KeyCode.ENTER) {
Expand Down
1 change: 1 addition & 0 deletions src/MenuItemGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class MenuItemGroup extends React.Component {
renderMenuItem: PropTypes.func,
index: PropTypes.number,
className: PropTypes.string,
subMenuKey: PropTypes.string,
rootPrefixCls: PropTypes.string,
};

Expand Down
47 changes: 26 additions & 21 deletions src/SubMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class SubMenu extends React.Component {
onTitleMouseLeave: PropTypes.func,
onTitleClick: PropTypes.func,
isOpen: PropTypes.bool,
store: PropTypes.object,
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']),
manualRef: PropTypes.func,
};

static defaultProps = {
Expand All @@ -66,6 +69,8 @@ export class SubMenu extends React.Component {
onTitleMouseEnter: noop,
onTitleMouseLeave: noop,
onTitleClick: noop,
manualRef: noop,
mode: 'vertical',
title: '',
};

Expand All @@ -90,20 +95,6 @@ export class SubMenu extends React.Component {
this.componentDidUpdate();
}

adjustWidth = () => {
/* istanbul ignore if */
if (!this.subMenuTitle || !this.menuInstance) {
return;
}
const popupMenu = ReactDOM.findDOMNode(this.menuInstance);
if (popupMenu.offsetWidth >= this.subMenuTitle.offsetWidth) {
return;
}

/* istanbul ignore next */
popupMenu.style.minWidth = `${this.subMenuTitle.offsetWidth}px`;
};

componentDidUpdate() {
const { mode, parentMenu, manualRef } = this.props;

Expand Down Expand Up @@ -134,9 +125,9 @@ export class SubMenu extends React.Component {
if (this.mouseenterTimeout) {
clearTimeout(this.mouseenterTimeout);
}
};
}

onDestroy(key) {
onDestroy = (key) => {
this.props.onDestroy(key);
};

Expand Down Expand Up @@ -325,6 +316,24 @@ export class SubMenu extends React.Component {
return this.props.openKeys.indexOf(this.props.eventKey) !== -1;
}

adjustWidth = () => {
/* istanbul ignore if */
if (!this.subMenuTitle || !this.menuInstance) {
return;
}
const popupMenu = ReactDOM.findDOMNode(this.menuInstance);
if (popupMenu.offsetWidth >= this.subMenuTitle.offsetWidth) {
return;
}

/* istanbul ignore next */
popupMenu.style.minWidth = `${this.subMenuTitle.offsetWidth}px`;
};

saveSubMenuTitle = (subMenuTitle) => {
this.subMenuTitle = subMenuTitle;
}

renderChildren(children) {
const props = this.props;
const baseProps = {
Expand Down Expand Up @@ -394,10 +403,6 @@ export class SubMenu extends React.Component {
);
}

saveSubMenuTitle = (subMenuTitle) => {
this.subMenuTitle = subMenuTitle;
}

render() {
const props = this.props;
const isOpen = props.isOpen;
Expand Down Expand Up @@ -490,7 +495,7 @@ export class SubMenu extends React.Component {
</li>
);
}
};
}

const connected = connect(({ openKeys, activeKey, selectedKeys }, { eventKey, subMenuKey }) => ({
isOpen: openKeys.indexOf(eventKey) > -1,
Expand Down
Loading

0 comments on commit e1d27b9

Please sign in to comment.