From ad294d1d76f9c95e4a8d0c7de1856923a2f71bc6 Mon Sep 17 00:00:00 2001 From: David Pene Date: Fri, 28 Aug 2015 16:35:48 +1200 Subject: [PATCH 001/314] adding css for searching box --- less/menu.less | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/less/menu.less b/less/menu.less index 8fa78f6b7c..2906579b50 100644 --- a/less/menu.less +++ b/less/menu.less @@ -1,4 +1,4 @@ -// +// // Select Menu // ------------------------------ @@ -7,8 +7,8 @@ .Select-menu-outer { // Unfortunately, having both border-radius and allows scrolling using overflow defined on the same - // element forces the browser to repaint on scroll. However, if these definitions are split into an - // outer and an inner element, the browser is able to optimize the scrolling behavior and does not + // element forces the browser to repaint on scroll. However, if these definitions are split into an + // outer and an inner element, the browser is able to optimize the scrolling behavior and does not // have to repaint on scroll. .border-bottom-radius( @select-input-border-radius ); @@ -47,7 +47,7 @@ &:last-child { .border-bottom-radius( @select-input-border-radius ); } - + &.is-focused { background-color: @select-option-focused-bg; color: @select-option-focused-color; @@ -64,7 +64,8 @@ // no results .Select-noresults, -.Select-search-prompt { +.Select-search-prompt, +.Select-searching { box-sizing: border-box; color: @select-noresults-color; cursor: default; From d902aab8b569fcd1bbeba3b51975b3b23d2e4a6e Mon Sep 17 00:00:00 2001 From: Tom Leslie Date: Fri, 28 Aug 2015 09:46:49 -0500 Subject: [PATCH 002/314] Adding onInputChange handler that returns the current input value. --- src/Select.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index bb4c2688b8..5f2240afba 100644 --- a/src/Select.js +++ b/src/Select.js @@ -41,6 +41,7 @@ var Select = React.createClass({ onBlur: React.PropTypes.func, // onBlur handler: function(event) {} onChange: React.PropTypes.func, // onChange handler: function(newValue) {} onFocus: React.PropTypes.func, // onFocus handler: function(event) {} + onInputChange: React.PropTypes.func, // onInputChange handler: function(inputValue) {} onOptionLabelClick: React.PropTypes.func, // onCLick handler for value labels: function (value, event) {} optionComponent: React.PropTypes.func, // option component to render in dropdown optionRenderer: React.PropTypes.func, // optionRenderer: function(option) {} @@ -77,6 +78,7 @@ var Select = React.createClass({ newOptionCreator: undefined, noResultsText: 'No results found', onChange: undefined, + onInputChange: undefined, onOptionLabelClick: undefined, optionComponent: Option, options: undefined, @@ -465,7 +467,11 @@ var Select = React.createClass({ return; } break; - default: return; + default: + if (this.props.onInputChange) { + this.props.onInputChange(this.state.inputValue); + } + return; } event.preventDefault(); }, From 9a596e9ad6cbe698e2cc529ccc8a9a3a7b804d81 Mon Sep 17 00:00:00 2001 From: Tom Leslie Date: Fri, 28 Aug 2015 10:27:46 -0500 Subject: [PATCH 003/314] Adding test for onInputChange. --- test/Select-test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/Select-test.js b/test/Select-test.js index a070a122ac..98a8d99b4d 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -45,7 +45,7 @@ class PropsWrapper extends React.Component { } describe('Select', function() { - var options, onChange; + var options, onChange, onInputChange; var instance, wrapper; var searchInputNode; @@ -53,6 +53,10 @@ describe('Select', function() { return React.findDOMNode(instance).querySelector('.Select-control'); } + function enterSingleCharacter() { + TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 65, key: 'a' }); + } + function pressEnterToAccept() { TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 13, key: 'Enter' }); } @@ -107,10 +111,12 @@ describe('Select', function() { var createControl = function(props) { onChange = sinon.spy(); + onInputChange = sinon.spy(); // Render an instance of the component instance = TestUtils.renderIntoDocument( ` elements should be considered private and prone to change. + +```js +// focuses the input element +.focus(); +``` # Contributing From a08b69537ea4a3e63378fd8bb2acfc274458f8a9 Mon Sep 17 00:00:00 2001 From: Tom Leslie Date: Mon, 31 Aug 2015 08:55:18 -0500 Subject: [PATCH 009/314] Handling the input change in a more appropriate place. --- src/Select.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Select.js b/src/Select.js index 5f2240afba..ff27da46b2 100644 --- a/src/Select.js +++ b/src/Select.js @@ -467,11 +467,7 @@ var Select = React.createClass({ return; } break; - default: - if (this.props.onInputChange) { - this.props.onInputChange(this.state.inputValue); - } - return; + default: return; } event.preventDefault(); }, @@ -492,6 +488,10 @@ var Select = React.createClass({ // the latest value before setState() has completed. this._optionsFilterString = event.target.value; + if (this.props.onInputChange) { + this.props.onInputChange(event.target.value); + } + if (this.props.asyncOptions) { this.setState({ isLoading: true, From f7bbbfa81f0314bdf4159628de35f65f27a03219 Mon Sep 17 00:00:00 2001 From: "Alan R. Soares" Date: Fri, 4 Sep 2015 11:22:49 +1200 Subject: [PATCH 010/314] prevent value splitting on non-multi-value select --- src/Select.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index bb4c2688b8..48c25032dc 100644 --- a/src/Select.js +++ b/src/Select.js @@ -265,7 +265,11 @@ var Select = React.createClass({ initValuesArray: function(values, options) { if (!Array.isArray(values)) { if (typeof values === 'string') { - values = values === '' ? [] : values.split(this.props.delimiter); + values = values === '' + ? [] + : this.props.multi + ? values.split(this.props.delimiter) + : [ values ]; } else { values = values !== undefined && values !== null ? [values] : []; } From a82b76d1f8730d5cff1d7975f4eb8afb3b2f10cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Montlouis-Calixte=20St=C3=A9phane?= Date: Fri, 4 Sep 2015 15:20:59 +0200 Subject: [PATCH 011/314] Support mobile click --- src/Select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index bb4c2688b8..abb885a56e 100644 --- a/src/Select.js +++ b/src/Select.js @@ -786,7 +786,7 @@ var Select = React.createClass({ } var loading = this.state.isLoading ?