Fluentui: Dropdown calls onChange before callout is dismissed

Created on 4 Oct 2019  路  7Comments  路  Source: microsoft/fluentui

Environment Information

  • Package version(s): 7.43.0
  • Browser and OS versions: Chrome 77.0.3865.90, Windows 10

Please provide a reproduction of the bug in a codepen:


https://codepen.io/aboktor/pen/LYYPdwO

Actual behavior:

When a dropdown with no defaultSelectedKey is clicked, onChange is called with the first item in options BEFORE the callout is dismissed

Expected behavior:

onChange is not called until the user actually selects an option or focus blur. Only at that time should onChange be called with the option the user selected or the first option (in case of blur).

Priorities and help requested:

Are you willing to submit a PR to fix? (Yes, No)
Yes
Requested priority: (Blocking, High, Normal, Low)
High
Products/sites affected: (if applicable)
Can't disclose this right now, not released publicly

Dropdown Fixed Type

All 7 comments

Hi @aboktor, thanks for filing this issue! I've checked your codepen and I can confirm that the behavior you've described is the actual behavior exhibited. However, I wonder if this is really a bug or a decision by design. @joschect, any thoughts on this?

However, I wonder if this is really a bug or a decision by design. @joschect, any thoughts on this?

Another thing you can take a look at in the codepen, click the dropdown then select any item that's not the first. You'd get two onChange calls for what is essentially a single selection.

@aboktor, thanks for that other scenario, we'll take it into account when making a decision.

@aboktor I believe that you're right that this is by design. There has been this longstanding issue which details why we automatically select the first dropdown item, even when the user has not taken action to select one.

@aboktor are you fine tracking that other issue and closing this one? It seems that the conversation and context on this is there.

@khmakoto @joschect the longstanding issue is with regards to the first option being selected when focused, but I think it is a separate issue from what is being reported here. I think the ask that we don't trigger onChange event until a blur event when the Dropdown is expanded is reasonable, and can be made in isolation.

:tada:This issue was addressed in #10755, which has now been successfully released as [email protected].:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings