Skip to content

Commit

Permalink
fix(Menu): keyboard not blur
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Dec 7, 2018
1 parent 41c13aa commit dda5a16
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/menu/view/menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default class Menu extends Component {
focusedKey: PropTypes.string,
focusable: PropTypes.bool,
onItemFocus: PropTypes.func,
onBlur: PropTypes.func,
onItemKeyDown: PropTypes.func,
expandAnimation: PropTypes.bool,
itemClassName: PropTypes.string
Expand Down Expand Up @@ -195,7 +196,7 @@ export default class Menu extends Component {
focusedKey: 'focusedKey' in this.props ? focusedKey : (focusable && autoFocus ? this.tabbableKey : null)
};

bindCtx(this, ['handleOpen', 'handleSelect', 'handleItemClick', 'handleItemKeyDown']);
bindCtx(this, ['handleOpen', 'handleSelect', 'handleItemClick', 'handleItemKeyDown', 'onBlur']);

this.popupNodes = [];
}
Expand Down Expand Up @@ -235,6 +236,14 @@ export default class Menu extends Component {
}
}

onBlur(e) {
this.setState({
focusedKey: ''
});

this.props.onBlur && this.props.onBlur(e);
}

getInitOpenKeys(props) {
let initOpenKeys;

Expand Down Expand Up @@ -629,7 +638,7 @@ export default class Menu extends Component {
}

return (
<ul role={role} className={newClassName} onKeyDown={this.handleEnter} aria-multiselectable={selectMode === 'multiple'} {...others}>
<ul role={role} onBlur={this.onBlur} className={newClassName} onKeyDown={this.handleEnter} aria-multiselectable={selectMode === 'multiple'} {...others}>
{headerElement}
{shouldWrapItemsAndFooter ?
<div className={`${prefix}menu-hoz-right`}>
Expand Down

0 comments on commit dda5a16

Please sign in to comment.