reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

handleKeyUp does not work for Enter key from 1.5.7 #250

Closed kyle306 closed 7 years ago

kyle306 commented 7 years ago

Hi,

In my project, I have to handle the event of typing enter key in the input. First I get the ref of the component (ref={el=>this.input=el}) and then overwrite the handler (this.input.handleKeyUp=function(proxy){...}) in the componentDidMount.

I used handleKeyUp instead of the handleKeyDown to prevent the multiple triggers of the action in tiny duration.

I find this approach does not work from 1.5.7 as pressing enter key does not trigger the key up event. Is there any approach to do so?

Thanks.

CMTegner commented 7 years ago

Hi Kyle! We removed the internal handleKeyDown method due to it no longer being needed after we rewrote the auto highlight logic.

In my project, I have to handle the event of typing enter key in the input.

Have you tried using props.onKeyUp?

I used handleKeyUp instead of the handleKeyDown to prevent the multiple triggers of the action in tiny duration.

Which action is this?

kyle306 commented 7 years ago

HI CMTegner

I tried the following on 1.5.9 <Autocomplete ... onKeyUp={()=>console.log('Key Up')}

Nothing happened in the console when I type Enter key in the input.

CMTegner commented 7 years ago

Sorry, I meant to write inputProps.onKeyUp.

kyle306 commented 7 years ago

I tried inputProps.onKeyUp and it worked. Thanks a lot!

CMTegner commented 7 years ago

Great! Just out of curiosity, what kind of behaviour did you need to add?