Skip to content

Commit 898dba3

Browse files
committed
Fix for the FieldTaxonomyRenderer field
1 parent 35550ff commit 898dba3

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Releases
22

3+
## 1.2.1
4+
5+
**Fixes**
6+
7+
- `FieldTaxonomyRenderer` got fixed to support single and multiple values
8+
39
## 1.2.0
410

511
**New controls**

docs/documentation/docs/about/release-notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Releases
22

3+
## 1.2.1
4+
5+
**Fixes**
6+
7+
- `FieldTaxonomyRenderer` got fixed to support single and multiple values
8+
39
## 1.2.0
410

511
**New controls**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pnp/spfx-controls-react",
33
"description": "Reusable React controls for SharePoint Framework solutions",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"engines": {
66
"node": ">=0.10.0"
77
},

src/controls/fields/fieldTaxonomyRenderer/FieldTaxonomyRenderer.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface IFieldTaxonomyRendererProps extends IFieldRendererProps {
1111
/**
1212
* terms to display
1313
*/
14-
terms: ITerm[];
14+
terms: ITerm | ITerm[];
1515
}
1616

1717
/**
@@ -35,9 +35,14 @@ export class FieldTaxonomyRenderer extends React.Component<IFieldTaxonomyRendere
3535

3636
@override
3737
public render(): JSX.Element {
38-
const termEls: JSX.Element[] = this.props.terms.map((term) => {
39-
return <div className={styles.term} style={this.props.cssProps}><span>{term.Label}</span></div>;
40-
});
38+
let termEls: JSX.Element | JSX.Element[] = null;
39+
if (Array.isArray(this.props.terms)) {
40+
termEls = this.props.terms.map((term) => {
41+
return <div className={styles.term} style={this.props.cssProps}><span>{term.Label}</span></div>;
42+
});
43+
} else {
44+
termEls = <div className={styles.term} style={this.props.cssProps}><span>{this.props.terms.Label}</span></div>;
45+
}
4146
return (<div style={this.props.cssProps} className={css(this.props.className)}>{termEls}</div>);
4247
}
4348
}

0 commit comments

Comments
 (0)