Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix not clearing when given invalid values #1756

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1794,8 +1794,8 @@ var Select = (0, _createReactClass2['default'])({
},

renderClear: function renderClear() {

if (!this.props.clearable || this.props.value === undefined || this.props.value === null || this.props.multi && !this.props.value.length || this.props.disabled || this.props.isLoading) return;
var valueArray = this.getValueArray(this.props.value);
if (!this.props.clearable || valueArray.length === 0 || this.props.disabled || this.props.isLoading) return;
var clear = this.props.clearRenderer();

return _react2['default'].createElement(
Expand Down
4 changes: 2 additions & 2 deletions dist/react-select.min.js

Large diffs are not rendered by default.

124 changes: 72 additions & 52 deletions examples/dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ module.exports = function() {
require('whatwg-fetch');
module.exports = self.fetch.bind(self);

},{"whatwg-fetch":83}],24:[function(require,module,exports){
},{"whatwg-fetch":82}],24:[function(require,module,exports){
(function(){
var crypt = require('crypt'),
utf8 = require('charenc').utf8,
Expand Down Expand Up @@ -1766,25 +1766,27 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {

},{}],26:[function(require,module,exports){
(function (process){
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime;
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;

if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
return performance.now();
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - loadTime) / 1e6;
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
loadTime = getNanoSeconds();
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
Expand All @@ -1799,6 +1801,8 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {

}).call(this);



}).call(this,require('_process'))
},{"_process":27}],27:[function(require,module,exports){
// shim for using process in browser
Expand Down Expand Up @@ -1971,6 +1975,10 @@ process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;

process.listeners = function (name) { return [] }

process.binding = function (name) {
throw new Error('process.binding is not supported');
Expand Down Expand Up @@ -2031,9 +2039,9 @@ function parserForArrayFormat(opts) {
switch (opts.arrayFormat) {
case 'index':
return function (key, value, accumulator) {
result = /\[(\d*)]$/.exec(key);
result = /\[(\d*)\]$/.exec(key);

key = key.replace(/\[\d*]$/, '');
key = key.replace(/\[\d*\]$/, '');

if (!result) {
accumulator[key] = value;
Expand All @@ -2049,13 +2057,15 @@ function parserForArrayFormat(opts) {

case 'bracket':
return function (key, value, accumulator) {
result = /(\[])$/.exec(key);

key = key.replace(/\[]$/, '');
result = /(\[\])$/.exec(key);
key = key.replace(/\[\]$/, '');

if (!result || accumulator[key] === undefined) {
if (!result) {
accumulator[key] = value;
return;
} else if (accumulator[key] === undefined) {
accumulator[key] = [value];
return;
}

accumulator[key] = [].concat(accumulator[key], value);
Expand Down Expand Up @@ -2187,7 +2197,7 @@ exports.stringify = function (obj, opts) {
}).join('&') : '';
};

},{"object-assign":25,"strict-uri-encode":82}],29:[function(require,module,exports){
},{"object-assign":25,"strict-uri-encode":81}],29:[function(require,module,exports){
(function (global){
var now = require('performance-now')
, root = typeof window === 'undefined' ? global : window
Expand Down Expand Up @@ -2264,8 +2274,36 @@ module.exports.polyfill = function() {

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"performance-now":26}],30:[function(require,module,exports){
module.exports = require('react/lib/shallowCompare');
},{"react/lib/shallowCompare":81}],31:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule shallowCompare
*/

'use strict';

var shallowEqual = require('fbjs/lib/shallowEqual');

/**
* Does a shallow comparison for props and state.
* See ReactComponentWithPureRenderMixin
* See also https://facebook.github.io/react/docs/shallow-compare.html
*/
function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
}

module.exports = shallowCompare;

},{"fbjs/lib/shallowEqual":20}],31:[function(require,module,exports){
'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
Expand All @@ -2288,6 +2326,10 @@ var _isRetina = require('is-retina');

var _isRetina2 = _interopRequireDefault(_isRetina);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
Expand All @@ -2304,7 +2346,7 @@ var Gravatar = function (_React$Component) {
function Gravatar() {
_classCallCheck(this, Gravatar);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Gravatar).apply(this, arguments));
return _possibleConstructorReturn(this, (Gravatar.__proto__ || Object.getPrototypeOf(Gravatar)).apply(this, arguments));
}

_createClass(Gravatar, [{
Expand All @@ -2331,7 +2373,7 @@ var Gravatar = function (_React$Component) {
if (this.props.md5) {
hash = this.props.md5;
} else if (typeof this.props.email === 'string') {
hash = (0, _md2.default)(formattedEmail);
hash = (0, _md2.default)(formattedEmail, { encoding: "binary" });
} else {
console.warn('Gravatar image can not be fetched. Either the "email" or "md5" prop must be specified.');
return _react2.default.createElement('script', null);
Expand Down Expand Up @@ -2394,14 +2436,14 @@ var Gravatar = function (_React$Component) {

Gravatar.displayName = 'Gravatar';
Gravatar.propTypes = {
email: _react2.default.PropTypes.string,
md5: _react2.default.PropTypes.string,
size: _react2.default.PropTypes.number,
rating: _react2.default.PropTypes.string,
default: _react2.default.PropTypes.string,
className: _react2.default.PropTypes.string,
protocol: _react2.default.PropTypes.string,
style: _react2.default.PropTypes.object
email: _propTypes2.default.string,
md5: _propTypes2.default.string,
size: _propTypes2.default.number,
rating: _propTypes2.default.string,
default: _propTypes2.default.string,
className: _propTypes2.default.string,
protocol: _propTypes2.default.string,
style: _propTypes2.default.object
};
Gravatar.defaultProps = {
size: 50,
Expand All @@ -2412,7 +2454,7 @@ Gravatar.defaultProps = {


module.exports = Gravatar;
},{"is-retina":22,"md5":24,"query-string":28,"react":undefined}],32:[function(require,module,exports){
},{"is-retina":22,"md5":24,"prop-types":undefined,"query-string":28,"react":undefined}],32:[function(require,module,exports){
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -9477,39 +9519,14 @@ module.exports = {
removeResizeListener: removeResizeListener
};
},{}],81:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/

'use strict';

var shallowEqual = require('fbjs/lib/shallowEqual');

/**
* Does a shallow comparison for props and state.
* See ReactComponentWithPureRenderMixin
* See also https://facebook.github.io/react/docs/shallow-compare.html
*/
function shallowCompare(instance, nextProps, nextState) {
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
}

module.exports = shallowCompare;
},{"fbjs/lib/shallowEqual":20}],82:[function(require,module,exports){
'use strict';
module.exports = function (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
});
};

},{}],83:[function(require,module,exports){
},{}],82:[function(require,module,exports){
(function(self) {
'use strict';

Expand Down Expand Up @@ -9596,7 +9613,10 @@ module.exports = function (str) {
headers.forEach(function(value, name) {
this.append(name, value)
}, this)

} else if (Array.isArray(headers)) {
headers.forEach(function(header) {
this.append(header[0], header[1])
}, this)
} else if (headers) {
Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name])
Expand Down
4 changes: 2 additions & 2 deletions examples/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2070,8 +2070,8 @@ var Select = (0, _createReactClass2['default'])({
},

renderClear: function renderClear() {

if (!this.props.clearable || this.props.value === undefined || this.props.value === null || this.props.multi && !this.props.value.length || this.props.disabled || this.props.isLoading) return;
var valueArray = this.getValueArray(this.props.value);
if (!this.props.clearable || valueArray.length === 0 || this.props.disabled || this.props.isLoading) return;
var clear = this.props.clearRenderer();

return _react2['default'].createElement(
Expand Down
Loading