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

Dropdown: calls onChange even when value is not changed #3437

Closed
mic4ael opened this issue Feb 14, 2019 · 10 comments · Fixed by #3482
Closed

Dropdown: calls onChange even when value is not changed #3437

mic4ael opened this issue Feb 14, 2019 · 10 comments · Fixed by #3482

Comments

@mic4ael
Copy link
Contributor

mic4ael commented Feb 14, 2019

Bug Report

Steps

  1. Open https://codesandbox.io/s/jpnzzkl7pv
  2. Open the first dropdown and select the "text4" option
  3. Open the same dropdown again and select the "text4"

Expected result

onChange was called once as value wan't changed. The native <select /> has the same behavior.

Actual result

onChange was called twice.

Version

0.85.0

Testcase

https://codesandbox.io/s/jpnzzkl7pv

@mic4ael
Copy link
Contributor Author

mic4ael commented Feb 14, 2019

What is also worth mentioning is that this doesn't happen if you actually select an option from the list by clicking it.

@layershifter
Copy link
Member

It comes from #3391 that fixes #3370.

@mic4ael Can you please describe steps more detailed? I've made another codesandbox (https://codesandbox.io/s/jpnzzkl7pv), actually behavior looks correct to me.

@mic4ael
Copy link
Contributor Author

mic4ael commented Feb 14, 2019

In that case that is partially broken because just like I mentioned, this doesn't happen when you actually click the option instead of clicking outside of the dropdown.

@mic4ael
Copy link
Contributor Author

mic4ael commented Feb 14, 2019

  1. Create a dropdown with a few options
  2. Select one of them by clicking it
  3. Select the same option by clicking it.

Result is that onChange is triggered.

  1. Create a dropdown with a few options
  2. Select one of them by clicking it
  3. Select the same option by typing it and clicking outside of the Dropdown.

Result is that onChange is not triggered.

@layershifter
Copy link
Member

  • Select one of them by clicking it
  • Select the same option by clicking it.

Actually, it's a wrong behavior, you can compare it with a native <select />: https://codesandbox.io/s/jpnzzkl7pv

  • Select one of them by clicking it
  • Select the same option by typing it and clicking outside of the Dropdown.

So the value is not changed on these steps, right? Actually, it's a correct behavior, see #3370.

@mic4ael
Copy link
Contributor Author

mic4ael commented Feb 14, 2019

So, at least I think that the first case I presented is a bug, right?

@layershifter
Copy link
Member

Yep, we should not call onChange when the selected value is not changed.

Steps

  1. Open https://codesandbox.io/s/jpnzzkl7pv
  2. Open the first dropdown and select the "text4" option
  3. Open the same dropdown again and select the "text4"

Expected result

onChange was called once as value wan't changed.

Actual result

onChange was called twice.

@layershifter layershifter changed the title Dropdown: Clicking outside of a Dropdown component doesn't trigger onChange Dropdown: calls onChange even when value is not changed\ Feb 14, 2019
@layershifter layershifter changed the title Dropdown: calls onChange even when value is not changed\ Dropdown: calls onChange even when value is not changed Feb 14, 2019
@mic4ael
Copy link
Contributor Author

mic4ael commented Feb 15, 2019

I would like to work on this one if there are no objections.

@layershifter
Copy link
Member

Feel free to pick up it 👍

@jongsue
Copy link
Contributor

jongsue commented Mar 8, 2019

sorry @mic4ael if you're working on this

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

Successfully merging a pull request may close this issue.

3 participants