Skip to content

Commit

Permalink
Adding openOnClick prop, closes JedWatson#1994
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Sep 13, 2017
1 parent b13e01b commit 36bdf9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# React-Select

## Unreleased

* changed; `openAfterFocus` prop has been renamed to `openOnClick`, and now default to `true`

## v1.0.0-rc.8 / 2017-09-13

* fixed; clearable padding style, thanks [Minori Miyauchi](https://github.com/mmiyauchi)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ function onInputKeyDown(event) {
| onOpen | func | undefined | handler for when the menu opens: `function () {}` |
| onSelectResetsInput | bool | true | whether the input value should be reset when options are selected, for `multi`
| onValueClick | func | undefined | onClick handler for value labels: `function (value, event) {}` |
| openOnFocus | bool | false | open the options menu when the input gets focus (requires searchable = true) |
| openOnClick | bool | true | open the options menu when the control is clicked (requires searchable = true) |
| openOnFocus | bool | false | open the options menu when the control gets focus (requires searchable = true) |
| optionRenderer | func | undefined | function which returns a custom way to render the options in the menu |
| options | array | undefined | array of options |
| placeholder | string\|node | 'Select ...' | field placeholder, displayed when there's no value |
Expand Down
7 changes: 4 additions & 3 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class Select extends React.Component {
});
} else {
// otherwise, focus the input and open the menu
this._openAfterFocus = this.props.openAfterFocus;
this._openAfterFocus = this.props.openOnClick;
this.focus();
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class Select extends React.Component {
}
this.setState({
isFocused: true,
isOpen: isOpen
isOpen: isOpen,
});
this._openAfterFocus = false;
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@ Select.propTypes = {
onOpen: PropTypes.func, // fires when the menu is opened
onSelectResetsInput: PropTypes.bool, // whether input is cleared on select (works only for multiselect)
onValueClick: PropTypes.func, // onClick handler for value labels: function (value, event) {}
openAfterFocus: PropTypes.bool, // boolean to enable opening dropdown when focused
openOnClick: PropTypes.bool, // boolean to control opening the menu when the control is clicked
openOnFocus: PropTypes.bool, // always open options menu on focus
optionClassName: PropTypes.string, // additional class(es) to apply to the <Option /> elements
optionComponent: PropTypes.func, // option component to render in dropdown
Expand Down Expand Up @@ -1149,6 +1149,7 @@ Select.defaultProps = {
onBlurResetsInput: true,
onSelectResetsInput: true,
onCloseResetsInput: true,
openOnClick: true,
optionComponent: Option,
pageSize: 5,
placeholder: 'Select...',
Expand Down

0 comments on commit 36bdf9c

Please sign in to comment.