Semantic-ui-react: Dropdown: calls `onChange` even when value is not changed

Created on 14 Feb 2019  路  10Comments  路  Source: Semantic-Org/Semantic-UI-React

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

bug help wanted

All 10 comments

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

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.

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.

  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.

  • 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.

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

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.

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

Feel free to pick up it 馃憤

sorry @mic4ael if you're working on this

Was this page helpful?
0 / 5 - 0 ratings