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

Clear button does not fire onChange in multi-select mode #672

Closed
alexey-vaiman opened this issue Sep 24, 2021 · 5 comments
Closed

Clear button does not fire onChange in multi-select mode #672

alexey-vaiman opened this issue Sep 24, 2021 · 5 comments
Labels

Comments

@alexey-vaiman
Copy link

Hello!

https://codesandbox.io/s/nice-proskuriakova-q64wz?file=/src/index.js

  1. Open sandbox console.
  2. Type three or more chars in typeahead input and in half a second dropdown opens showing options (based on your input). Select some option — console shows selection array (2 for first time and so on)
  3. Remove one option — console shows selection array (1 this time)
  4. Add and remove options — console shows selection array
  5. Make sure there is anything selected and press "clear" button — console DOES NOT SHOW empty array
    That was with react-bootstrap-typeahead version 5.2. Change version to 5.1.14. Do same steps — console SHOWS empty array after pressing "clear" button.

Turns out onChange is not called after pressing "clear". Must be something simple.
Thank you.

@alexey-vaiman
Copy link
Author

5.1.14 Typeahead.js:
_handleClear = () => { this.setState(clearTypeahead, () => this._handleChange([])); }
5.2 Typeahead.js:
_handleClear = () => { this.inputNode && triggerInputChange(this.inputNode, ''); this.setState(clearTypeahead); }

@ericgio
Copy link
Owner

ericgio commented Sep 24, 2021

Hi @alexey-vaiman thanks for opening this issue! It looks like the bug you're reporting would be addressed by #666, does that seem right?

@alexey-vaiman
Copy link
Author

Oh I didn't see that. You're right. My bad.

@ericgio
Copy link
Owner

ericgio commented Sep 27, 2021

No worries, just wanted to confirm it's the same bug! I'll leave this issue open for tracking purposes. Thanks again for the report.

@ericgio ericgio changed the title Clear button does not fire onChange Clear button does not fire onChange in multi-select mode Sep 27, 2021
@ericgio
Copy link
Owner

ericgio commented Oct 11, 2021

Fixed in v5.2.1

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

No branches or pull requests

2 participants