diff --git a/src/Select.js b/src/Select.js index bdb971fd1f..a79a004439 100644 --- a/src/Select.js +++ b/src/Select.js @@ -467,7 +467,9 @@ class Select extends React.Component { /** support optionally passing in the `nextProps` so `componentWillReceiveProps` updates will function as expected */ const props = typeof nextProps === 'object' ? nextProps : this.props; if (props.multi) { - if (typeof value === 'string') value = value.split(props.delimiter); + if (typeof value === 'string') { + value = value.split(props.delimiter); + } if (!Array.isArray(value)) { if (value === null || value === undefined) return []; value = [value]; @@ -489,7 +491,7 @@ class Select extends React.Component { let { options, valueKey } = props; if (!options) return; for (var i = 0; i < options.length; i++) { - if (options[i][valueKey] === value) return options[i]; + if (String(options[i][valueKey]) === String(value)) return options[i]; } } @@ -781,7 +783,7 @@ class Select extends React.Component { [this._instancePrefix + '-list']: isOpen, }); return ( - +
{ expect(instance, 'to contain', -
Two
-
One
+
Two
+
One
); }); @@ -738,8 +738,19 @@ describe('Select', () => { expect(instance, 'to contain', -
Three
-
Four
+
Three
+
Four
+
); + }); + it('supports updating the values as a string', () => { + wrapper.setPropsForChild({ + value: '3,4', + }); + + expect(instance, 'to contain', + +
Three
+
Four
); }); @@ -764,7 +775,7 @@ describe('Select', () => { expect(instance, 'to contain', -
Zero
+
Zero
); });