diff --git a/src/typeahead/option.js b/src/typeahead/option.js index b6dfc313..b2579938 100644 --- a/src/typeahead/option.js +++ b/src/typeahead/option.js @@ -33,8 +33,11 @@ var TypeaheadOption = React.createClass({ var classList = classNames(classes); + // For some reason onClick is not fired when clicked on an option + // onMouseDown is used here as a workaround of #205 and other + // related tickets return ( -
  • +
  • { this.props.children } diff --git a/test/typeahead-test.js b/test/typeahead-test.js index b01bacec..1eb01716 100644 --- a/test/typeahead-test.js +++ b/test/typeahead-test.js @@ -138,6 +138,27 @@ describe('Typeahead Component', function() { }); }); + describe('mouse controls', function() { + // as of React 15.5.4 this does not work + xit('mouse click selects an option (click event)', function() { + var results = simulateTextInput(this.component, 'o'); + var secondItem = ReactDOM.findDOMNode(results[1]); + var secondItemValue = secondItem.innerText; + var node = this.component.refs.entry; + TestUtils.Simulate.click(secondItem); + assert.equal(node.value, secondItemValue); + }); + // but this one works + it('mouse click selects an option (mouseDown event)', function() { + var results = simulateTextInput(this.component, 'o'); + var secondItem = ReactDOM.findDOMNode(results[1]); + var secondItemValue = secondItem.innerText; + var node = this.component.refs.entry; + TestUtils.Simulate.mouseDown(secondItem); + assert.equal(node.value, secondItemValue); + }); + }); + describe('component functions', function() { beforeEach(function() { this.sinon = sinon.sandbox.create();