diff --git a/src/AutoComplete.js b/src/AutoComplete.js index 16ba5d5..54d5c04 100644 --- a/src/AutoComplete.js +++ b/src/AutoComplete.js @@ -5,6 +5,7 @@ import mapError from './mapError' export default createComponent(AutoComplete, ({ input: { onChange, value }, onNewRequest, + onUpdateInput, dataSourceConfig, dataSource, ...props @@ -23,9 +24,13 @@ export default createComponent(AutoComplete, ({ onNewRequest(value) } }, - onUpdateInput: value => { + onUpdateInput: (value, ...restArgs) => { if (!dataSourceConfig) { onChange(value) } + + if (onUpdateInput) { + onUpdateInput(value, ...restArgs) + } } })) diff --git a/src/__tests__/AutoComplete.spec.js b/src/__tests__/AutoComplete.spec.js index 4d42fe0..a893e62 100644 --- a/src/__tests__/AutoComplete.spec.js +++ b/src/__tests__/AutoComplete.spec.js @@ -154,6 +154,30 @@ describe('AutoComplete', () => { expect(onChange).toHaveBeenCalled().toHaveBeenCalledWith('TheValue') }) + it('triggers onUpdateInput callback passed to component', () => { + const onUpdateInput = createSpy() + const params = { source: 'source' } + + const dom = TestUtils.renderIntoDocument( + + + + ) + + const autocomplete = TestUtils.findRenderedComponentWithType( + dom, + AutoComplete + ) + + expect(onUpdateInput).toNotHaveBeenCalled() + autocomplete.props.onUpdateInput('TheValue', dataSource, params) + expect(onUpdateInput).toHaveBeenCalled().toHaveBeenCalledWith('TheValue', dataSource, params) + }) + it('provides getRenderedComponent', () => { const dom = TestUtils.renderIntoDocument(