react-native-search-header icon indicating copy to clipboard operation
react-native-search-header copied to clipboard

Request - onClear prop

Open Noitidart opened this issue 6 years ago • 12 comments

May we please get an onClear prop. onClear I want to clear out my search results. I added it in manually for now, but it would be awesome so I dont have to manually add this in everytime i update the package.

Noitidart avatar Jan 19 '18 20:01 Noitidart

I'll get that feature implement for the next update soon. Thanks.

tuantle avatar Jan 24 '18 05:01 tuantle

Thank you so so much!!

Noitidart avatar Jan 24 '18 06:01 Noitidart

Is this what you are looking for?

<SearchHeader onClearSuggesstion = {() => true }/>

This will only clear if the function return true after componentWillReceiveProps is called.

There is also a clearSuggestion function that is called by ref.

tuantle avatar Feb 05 '18 22:02 tuantle

Oh no, what i was looking for was when user presses the "X" icon it should trigger callback. If possible that would be super awesome.

Noitidart avatar Feb 05 '18 22:02 Noitidart

Here is an example of what you can do with component ref method.

<SearchHeader ref = {(searchHeader) => { this.searchHeader = searchHeader; }} /> <View style = { styles.button }> <Button title = 'Clear Suggestion' onPress = {() => this.searchHeader.clearSuggestion()} /> </View>

tuantle avatar Feb 05 '18 22:02 tuantle

Thanks thats cool but then i have to implement my own styling on the clear button :(

Your stryling is perfect.

Noitidart avatar Feb 05 '18 22:02 Noitidart

@tuantle Really need this onClear() prop. This would trigger a callback when the (x) button is pressed or the text input data is cleared using clear() method.

adi23arora avatar Jun 07 '18 08:06 adi23arora

@adi23arora I have onClear callback prop implemented, but I did not put it in the docs and not tested. You can try it out to see if it is working. If not, I will fix it in the next update.

tuantle avatar Jun 07 '18 17:06 tuantle

@tuantle I guess it's not working. I tried it out but there's no change when the (x) button is pressed to clear the text input.

adi23arora avatar Jun 08 '18 12:06 adi23arora

I see. I'll will fit that and have an update in a day or two.

tuantle avatar Jun 08 '18 22:06 tuantle

Please update to version 0.2.7. I tested it, but let me know if it is still not working.

tuantle avatar Jun 12 '18 02:06 tuantle

@tuantle Thanks for the update, it's working now.

adi23arora avatar Jun 12 '18 07:06 adi23arora