Skip to content

Commit c45b958

Browse files
committed
Fix issue for #83
1 parent 5124b2c commit c45b958

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.JSON

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"enhancements": [
88
"Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)"
99
],
10-
"fixes": []
10+
"fixes": [
11+
"Bug in TaxonomyPicker where values are not updated by an async change [#83](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/83)"
12+
]
1113
},
1214
"contributions": []
1315
},

src/controls/taxonomyPicker/TaxonomyPicker.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
4141
appInsights.track('ReactTaxonomyPicker');
4242

4343
this.state = {
44-
activeNodes: typeof this.props.initialValues !== 'undefined' ? this.props.initialValues : [],
44+
activeNodes: this.props.initialValues || [],
4545
termSetAndTerms: null,
4646
loaded: false,
4747
openPanel: false,
@@ -55,6 +55,24 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
5555
this.termsFromPickerChanged = this.termsFromPickerChanged.bind(this);
5656
}
5757

58+
/**
59+
* componentWillMount lifecycle hook
60+
*/
61+
public componentWillMount(): void {
62+
this.setState({
63+
activeNodes: this.props.initialValues || []
64+
});
65+
}
66+
67+
/**
68+
* componentWillUpdate lifecycle hook
69+
*/
70+
public componentWillUpdate(nextProps: ITaxonomyPickerProps): void {
71+
this.setState({
72+
activeNodes: nextProps.initialValues || []
73+
});
74+
}
75+
5876
/**
5977
* Loads the list from SharePoint current web site
6078
*/

0 commit comments

Comments
 (0)