diff --git a/src/FilterMixin.js b/src/FilterMixin.js index 1ba314247..c143aa24e 100644 --- a/src/FilterMixin.js +++ b/src/FilterMixin.js @@ -8,15 +8,17 @@ export default { if (!input) { return true; } - const filterOption = this.props.filterOption; + const { filterOption } = this.props; if (!filterOption) { return true; - } - if (child.props.disabled) { + } else if (child.props.disabled) { return false; + } else if (typeof filterOption === 'function') { + return filterOption.call(this, input, child); } - return filterOption.call(this, input, child); + return true; }, + renderFilterOptions(inputValue) { return this.renderFilterOptionsFromChildren(this.props.children, true, inputValue); }, diff --git a/tests/FilterMixin.spec.js b/tests/FilterMixin.spec.js index 775f0b97a..453338df2 100644 --- a/tests/FilterMixin.spec.js +++ b/tests/FilterMixin.spec.js @@ -106,6 +106,17 @@ describe('FilterMixin', () => { ); }); + it('filterOption could be true as described in default value', () => { + const wrapper = render( + + ); + + expect(renderToJson(wrapper)).toMatchSnapshot(); + }); + describe('tag mode', () => { it('renders unlisted item in value', () => { const wrapper = render( diff --git a/tests/__snapshots__/FilterMixin.spec.js.snap b/tests/__snapshots__/FilterMixin.spec.js.snap index c083769c6..b2d506f92 100644 --- a/tests/__snapshots__/FilterMixin.spec.js.snap +++ b/tests/__snapshots__/FilterMixin.spec.js.snap @@ -1,5 +1,33 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`FilterMixin renderFilterOptionsFromChildren filterOption could be true as described in default value 1`] = ` + +`; + exports[`FilterMixin renderFilterOptionsFromChildren filters children by inputValue 1`] = `