Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onSearchChange proposal #13

Open
asessa opened this issue Apr 2, 2017 · 2 comments
Open

onSearchChange proposal #13

asessa opened this issue Apr 2, 2017 · 2 comments

Comments

@asessa
Copy link

asessa commented Apr 2, 2017

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 ?

@CvBlixen
Copy link
Contributor

CvBlixen commented Jun 2, 2017

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. 👍

@peacechen
Copy link
Contributor

Looks like this was fixed in d9987c1

Is that working as you expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants