javascript - React onClick event not being picked up -
i working on search component auto-complete functionality , running strange behavior. component consists of input (searchinput
) , list of type-ahead results (searchresultwrapper
).
clicking on type-ahead result should populate searchinput
field selected result , hide type-ahead results. losing focus on field should hide results.
sample code can found here: https://jsfiddle.net/chez/h22qfx45/.
the issue comes when comment in closeresults
function responsible changing state of component hide type-ahead results. when code activated, onclick
handler searchresult
no longer picked react.
there fundamental concept missing here. react disconnecting event listeners searchresult
component since hidden?
there's thing in js : onblur
called before onclick
.
to solve it, need replace onclick
onmousedown
.
here's code : https://jsfiddle.net/h22qfx45/5/
source : onclick() , onblur() ordering issue
Comments
Post a Comment