fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Dropdown in controlled mode (using IDropDownProps.selectedKey) mis-rendering current selection text when selecting

Open fengyue1013 opened this issue 9 years ago • 7 comments

Bug Report

  • Package version(s): (4.31.0)
  • Browser and OS versions: (fill this out if relevant)

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? (No)

Requested priority: (High)

Products/sites affected: (if applicable)

Describe the issue:

When using selectedKey prop to render dropdown in the controlled patter, the dropdown current selection won't change according to user selection

Actual behavior:

Selecting the second option, and then select the third(or 4th, 5th) option, the current selection text is still the second option

Expected behavior:

The current selection text should be the third(or 4th, 5th) option

If applicable, please provide a codepen repro: https://codepen.io/yudma/pen/MvoLLM?editors=1111

fengyue1013 avatar Aug 11 '17 09:08 fengyue1013

FYI, using the new prop: IDropdownProps.selectedKeys will mitigate this issue. I'm not sure whether this issue is related to issue #2422

fengyue1013 avatar Aug 11 '17 09:08 fengyue1013

I wasn't able to repro this bug locally.

micahgodbolt avatar Aug 11 '17 17:08 micahgodbolt

I can repro for 4.30.0-4.32.0, if you're unable to repro feel to reach out to me (alias: chrbar)

chriswbarrett avatar Aug 15 '17 01:08 chriswbarrett

This is creating a blocking problem within OWA Calendar. Can someone please explain to me how to use selectedKeys without having multiselect set to true. selectedKeys wont work correctly unless I set multiselect={true}.

melvsparks avatar Aug 17 '17 01:08 melvsparks

@melvsparks I was not able to get it to work

chriswbarrett avatar Aug 17 '17 02:08 chriswbarrett

Okay, finally figured out why the codepen example isn't working. Each time an item is selected, the selected key is set to true, and it appears that it's not being removed when other items are chosen.

image

Not sure why this isn't reproing locally, but at least I know where to look.

micahgodbolt avatar Aug 17 '17 16:08 micahgodbolt

If you move the options into the component (rather than as a variable array) they work https://codepen.io/micahgodbolt/pen/gxoQgw?editors=1111

Mutability is fun, right!?!

micahgodbolt avatar Aug 17 '17 16:08 micahgodbolt