Skip to content

Commit

Permalink
Separate mouseDown handlers for menu and main control. Fixes #471
Browse files Browse the repository at this point in the history
  • Loading branch information
Yishai Burt committed Sep 24, 2015
1 parent 11f5816 commit 30cbe94
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ var Select = React.createClass({
if (typeof values === 'string') {
values = values === ''
? []
: this.props.multi
: this.props.multi
? values.split(this.props.delimiter)
: [ values ];
} else {
Expand Down Expand Up @@ -381,6 +381,19 @@ var Select = React.createClass({
}
},

handleMouseDownOnMenu: function(event) {
// if the event was triggered by a mousedown and not the primary
// button, or if the component is disabled, ignore it.
if (this.props.disabled || (event.type === 'mousedown' && event.button !== 0)) {
return;
}
event.stopPropagation();
event.preventDefault();

this._openAfterFocus = true;
this.getInputNode().focus();
},

handleMouseDownOnArrow: function(event) {
// if the event was triggered by a mousedown and not the primary
// button, or if the component is disabled, ignore it.
Expand Down Expand Up @@ -808,7 +821,7 @@ var Select = React.createClass({
menuProps = {
ref: 'menu',
className: 'Select-menu',
onMouseDown: this.handleMouseDown
onMouseDown: this.handleMouseDownOnMenu
};
menu = (
<div ref="selectMenuContainer" className="Select-menu-outer">
Expand Down

0 comments on commit 30cbe94

Please sign in to comment.