nkbt / react-debounce-input

React component that renders Input with debounced onChange
MIT License
451 stars 61 forks source link

onChange Fired When I Exit Input #60

Closed realph closed 7 years ago

realph commented 7 years ago

When I type inside my input field the onChange event is firing correctly, however when I click outside of the input field it also fires the onChange event.

onchange

My code looks like this:

search(query) {
  console.log('onChange fired');
}

render() {
  return (
    <DebounceInput minLength={2}
                    debounceTimeout={300}
                    onChange={ this.search }
                    placeholder="Search..." />
  );
}

Any idea why this might be happening? I had a look at the CodePen example and it doesn't seem to fire when clicking outside of the input.

Any help is appreciated. Thanks in advance!

nkbt commented 7 years ago

Oh that is intended behaviour. There is a flag (defaults to true) for this. https://github.com/nkbt/react-debounce-input#forcenotifyonblur-proptypesbool-default-true

realph commented 7 years ago

@nkbt Missed this option. Thanks!