react-typeahead icon indicating copy to clipboard operation
react-typeahead copied to clipboard

Option search is being run one change behind

Open Mr-Wallet opened this issue 9 years ago • 5 comments

When constructing a Typeahead with an array of strings as the object, each change brings up a list of options reflecting the input node's value before the change.

'' > no list
'a' > empty list
'ab' > list matching 'a'
'abc' > list matching 'ab'
'ab' [backspace] > list matching 'abc'
'abPASTED_TEXT' > list matching 'ab'
'abPASTED_TEXTc' > list matching 'abPASTED_TEXT'

Based on stepping through, it seems to be because componentWillReceiveProps is using this.state.entryValue to calculate the options, but the setState({entryValue}) in _onTextEntryUpdated hasn't yet been put into this.state at that point. As a result, even though the correct options are calculated in _onTextEntryUpdated, they're instantly overridden before the render occurs by a recalculation in componentWillReceiveProps using the previous state.

Mr-Wallet avatar Sep 09 '15 22:09 Mr-Wallet

Also having this issue.

mattvv avatar Sep 30 '15 17:09 mattvv

This seems to work fine on tokenizer though.

mattvv avatar Sep 30 '15 18:09 mattvv

I'm experiencing this as well

smith-kyle avatar Oct 09 '15 18:10 smith-kyle

I was experiencing this until i removed defaultValue="" from the component props.

juanmnl avatar Oct 20 '15 00:10 juanmnl

@fmoo Is there any chance you could take a look at the above PR which fixes this issue?

alexjg avatar Dec 09 '15 10:12 alexjg