Skip to content

Commit 3037dcb

Browse files
committed
fix of #367 and changelog
1 parent bd44bdf commit 3037dcb

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

CHANGELOG.JSON

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"versions": [
3+
{
4+
"version": "1.21.0",
5+
"changes": {
6+
"new": [],
7+
"enhancements": [],
8+
"fixes": [
9+
"`TaxonomyPicker`: Ability to reset the TaxonomyPicker (Remove all selected Terms) [#367](https://github.com/pnp/sp-dev-fx-controls-react/issues/367)"
10+
]
11+
}
12+
},
313
{
414
"version": "1.20.0",
515
"changes": {

src/controls/taxonomyPicker/TaxonomyPicker.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,26 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
7474
});
7575
}
7676

77-
/**
78-
* componentWillUpdate lifecycle hook
79-
*/
80-
public async componentDidUpdate(prevProps: ITaxonomyPickerProps): Promise<void> {
77+
78+
public componentWillReceiveProps(nextProps: ITaxonomyPickerProps) {
8179
let newState: ITaxonomyPickerState | undefined;
8280
// Check if the initial values objects are not equal, if that is the case, data can be refreshed
83-
if (!isEqual(this.props.initialValues, prevProps.initialValues)) {
81+
if (!isEqual(this.props.initialValues, nextProps.initialValues)) {
8482
newState = {
85-
activeNodes: this.props.initialValues || []
83+
activeNodes: nextProps.initialValues || []
8684
};
8785
}
8886

89-
if (this.props.errorMessage) {
87+
if (nextProps.errorMessage) {
9088
if (!newState) {
9189
newState = {};
9290
}
9391

94-
newState.errorMessage = this.props.errorMessage;
92+
newState.errorMessage = nextProps.errorMessage;
93+
}
94+
95+
if (newState) {
96+
this.setState(newState);
9597
}
9698
}
9799

0 commit comments

Comments
 (0)