File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,11 @@ var TypeaheadOption = React.createClass({
33
33
34
34
var classList = classNames ( classes ) ;
35
35
36
+ // For some reason onClick is not fired when clicked on an option
37
+ // onMouseDown is used here as a workaround of #205 and other
38
+ // related tickets
36
39
return (
37
- < li className = { classList } onClick = { this . _onClick } >
40
+ < li className = { classList } onClick = { this . _onClick } onMouseDown = { this . _onClick } >
38
41
< a href = "javascript: void 0;" className = { this . _getClasses ( ) } ref = "anchor" >
39
42
{ this . props . children }
40
43
</ a >
Original file line number Diff line number Diff line change @@ -138,6 +138,27 @@ describe('Typeahead Component', function() {
138
138
} ) ;
139
139
} ) ;
140
140
141
+ describe ( 'mouse controls' , function ( ) {
142
+ // as of React 15.5.4 this does not work
143
+ xit ( 'mouse click selects an option (click event)' , function ( ) {
144
+ var results = simulateTextInput ( this . component , 'o' ) ;
145
+ var secondItem = ReactDOM . findDOMNode ( results [ 1 ] ) ;
146
+ var secondItemValue = secondItem . innerText ;
147
+ var node = this . component . refs . entry ;
148
+ TestUtils . Simulate . click ( secondItem ) ;
149
+ assert . equal ( node . value , secondItemValue ) ;
150
+ } ) ;
151
+ // but this one works
152
+ it ( 'mouse click selects an option (mouseDown event)' , function ( ) {
153
+ var results = simulateTextInput ( this . component , 'o' ) ;
154
+ var secondItem = ReactDOM . findDOMNode ( results [ 1 ] ) ;
155
+ var secondItemValue = secondItem . innerText ;
156
+ var node = this . component . refs . entry ;
157
+ TestUtils . Simulate . mouseDown ( secondItem ) ;
158
+ assert . equal ( node . value , secondItemValue ) ;
159
+ } ) ;
160
+ } ) ;
161
+
141
162
describe ( 'component functions' , function ( ) {
142
163
beforeEach ( function ( ) {
143
164
this . sinon = sinon . sandbox . create ( ) ;
You can’t perform that action at this time.
0 commit comments