From 36bdf9c29e7d7c6fd145148f1b1130c11f3a77b3 Mon Sep 17 00:00:00 2001 From: Jed Watson Date: Wed, 13 Sep 2017 22:35:19 +1000 Subject: [PATCH] Adding openOnClick prop, closes #1994 --- HISTORY.md | 4 ++++ README.md | 3 ++- src/Select.js | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index be5768fa61..7252f3d4b2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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) diff --git a/README.md b/README.md index 328c40698b..ce8386d265 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/src/Select.js b/src/Select.js index 2492688444..e7d16d858d 100644 --- a/src/Select.js +++ b/src/Select.js @@ -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(); } } @@ -313,7 +313,7 @@ class Select extends React.Component { } this.setState({ isFocused: true, - isOpen: isOpen + isOpen: isOpen, }); this._openAfterFocus = false; } @@ -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