diff --git a/src/Creatable.js b/src/Creatable.js index dcfc03c0b2..6732d98398 100644 --- a/src/Creatable.js +++ b/src/Creatable.js @@ -92,7 +92,7 @@ const Creatable = React.createClass({ // This covers async edge-cases where a newly-created Option isn't yet in the async-loaded array. const excludeOptions = params[2] || []; - const filteredOptions = filterOptions(...params); + const filteredOptions = filterOptions(...params) || []; if (isValidNewOption({ label: this.inputValue })) { const { newOptionCreator } = this.props; diff --git a/test/Creatable-test.js b/test/Creatable-test.js index 8eb1903aa3..de6bfa42ff 100644 --- a/test/Creatable-test.js +++ b/test/Creatable-test.js @@ -102,6 +102,13 @@ describe('Creatable', () => { expect(values, 'to contain', 'three'); }); + it('should guard against invalid values returned by filterOptions', () => { + createControl({ + filterOptions: () => null + }); + typeSearchText('test');; + }); + it('should not show a "create..." prompt if current filter text is not a valid option (as determined by :isValidNewOption prop)', () => { createControl({ isValidNewOption: () => false