Event for clearing text inputs

It would be handy to have an event handler for when a user hits the clear button on a text input so that filters or search queries can be reset. I know that clearing a text input counts as a 'change' event, but I don't want to listen for changes as it means my search or filter queries get fired off on every keystroke.

There is an easy workaround which is to have a 'change' event listener that only triggers when value.length == 0, but thought it might be a useful feature to include.

Hi @krausenhaus!

As I was thinking through this feature request, and how we might manage the two exclusive behaviors without affecting existing apps, I had an idea. Would a setup like this work for you? Disable the event handler whenever the textinput has values in it?

That should only cause testQuery here to run when the input is cleared!

2 Likes

Cheers Alex, that's pretty much how I've got it set up now and it works just fine, so probably not that important of a feature request!

1 Like