question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Taxonomy Picker - initialValues should only require key and/or name

See original GitHub issue

Category

[x] Enhancement [ ] Bug [ ] Question

Version

[3.2.1]

Expected / Desired Behaviour / Question

When setting the default value (via initialValues) for the Taxonomy Picker, I should only need to provide the key and/or the name of the metadata properties to select.

Observed Behaviour

Taxonomy Picker initialValues requires an object of IPickerTerms which requires key, name, path and termset. Path cannot be retrieved from the API and termset is redundant as it would always be the same as the value provided to termsetNameOrID property of the control. As a workaround, I’m assigning a new object of type IPickerTerms with the correct key and name and empty string values “” for path and termset and I’m able to load the values correctly as well as save them using terms provided in onChange.

Steps to Reproduce

Follow the How to use sample and extend it to add a static initialValues as below (this should work, assuming you have these terms in your term store)

{[
  {
    key: "ee4bb03d-6046-4195-bd9f-f098fa990797",
    name: "Term1",
    path: "Parent1;Term1",
    termSet:"949a3a28-94db-447f-be03-13fada209e69"
  }
]}

I should only need to provide key and/or name - path and termSet should not be required

Happy to look into a PR to address this if this is agreed to be useful.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
joelfmrodriguescommented, Sep 9, 2021

@M365Bass Thanks for the feedback, it’s something that I have also experienced myself so completely understand the scenario. It’s handy to have the same interface as the change event as you may need to, for example, select items that were previously selected; but clearly has unnecessary properties when defining manually. I will update the documentation to include a note stating that path and termset can be empty values.

0reactions
joelfmrodriguescommented, Jan 12, 2022

@M365Bass documentation was updated previously and I have improved it slightly. As mentioned before, it is useful to maintain the same interface for objects, so the recommendation is to pass empty values for the properties that are not used if you don’t have their values at a given point. Many thanks for raising it, I will now close this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set TaxonomyPicker with initial values from term store SPFx
The problem is when I need to set the initial values of the component with the ones retrieved from the list column. I...
Read more >
PnP Taxonomy Picker in the SharePoint Framework (SPFx ...
This article provides steps to implement the PnP Taxonomy Picker in the SharePoint Framework (SPFx) web part, This Taxonomy Picker control ...
Read more >
reactjs - KQL - SPFx TaxonomyPicker (setting initial values)
Tried I have tried to just capture the term path in the QS (rather than all properties, key, name, path and termset) and...
Read more >
TaxonomyPicker - @pnp/spfx-controls-react
Taxonomy Picker. This control allows you to select one or more Terms from a TermSet via its name or TermSet ID. You can...
Read more >
How to use Single Value Taxonomy Picker Control in the ...
We need to have the @pnp/spfx-controls-react package installed in our SPFx web part. We can use the command below to install the package....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found