react-native-material-design-searchbar icon indicating copy to clipboard operation
react-native-material-design-searchbar copied to clipboard

onSearchChange proposal

Open asessa opened this issue 8 years ago • 2 comments

onSearchChange is fired when the text is change and on reset. The problem is that the function is called in 2 different ways, directly by passing the value of TextInput's onChangeText and via _onClose at https://github.com/ananddayalan/react-native-material-design-searchbar/blob/master/SearchBar.js#L77

What do you think if _onClose fires onSearchChange with just an empty string or we add a new event onInputClear / onInputReset ?

asessa avatar Apr 02 '17 09:04 asessa

I agree that this is a bit counter-intuitive.

To handle the current way of calling onSearchChange, my code looks like this:

<SearchBar
  onSearchChange={(query) => {
    if(typeof query != 'string')
      query = query.nativeEvent.text;
    this.props.onChangeSearchQuery(query);
  }}
  height={lookAndFeel.baseTextInputHeight}
  placeholder={'Search ...'}
  autoCorrect={false}
  padding={lookAndFeel.defaultPadding}
/>

Removing the if statement would be nice. 👍

CvBlixen avatar Jun 02 '17 08:06 CvBlixen

Looks like this was fixed in https://github.com/ananddayalan/react-native-material-design-searchbar/commit/d9987c18c6a0663a5bcdfbd4b87d204f2f45e1e3

Is that working as you expect?

peacechen avatar May 26 '18 02:05 peacechen