sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

PropertyPaneDropDown Selected=False after click

Open jm06-zz opened this issue 6 years ago • 3 comments

I am new to this as I used to develop VB .Net desktop applications. Quite a learning curve.

I added a DropDown (office-ui-fabric-react/lib/components/Dropdown) on a propertypane.

Annotation 2020-06-17 142915

The dropdown is populated dynamically and displays a set of lists holding a targeted content type. The idea is to select one and use the Title of the list in a call below this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl + /_api/web/lists/GetByTitle('${this.properties.listName}')/items?$orderby=Order1

When clicked, the item is selected and displays. The onChange is fired. The selectedKey is populated but nothing else happens. my properties remains Undefined.

SelectedFalse1Annotation 2020-06-17 140422

If this is a bug, is there a way round? How do you capture the selected value? Any code suggestions?

Jean-Marc

jm06-zz avatar Jun 17 '20 13:06 jm06-zz

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Jun 17 '20 13:06 msft-github-bot

First, this is more of a question about Office UI Fabric React vs. SharePoint... so you should post the question in their issue list/forums.

Second, this is by design & how the dropdown control works. The selected property is used to tell the dropdown in which item should be selected, but only from a presentation POV.

You use the selectedKey to get the value of the item that was selected. Ideally, you update the object selected to set it's selected property to true and update the state with the updated collection of items so it's re-rendered and shows the selected item.

andrewconnell avatar Jun 23 '20 09:06 andrewconnell

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

msft-github-bot avatar Jun 26 '20 10:06 msft-github-bot