Skip to content

Commit 1bec453

Browse files
committed
Fix for pnp#65
1 parent 5474e43 commit 1bec453

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- `TaxonomyPicker` control got added [#22](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/22) [#63](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/63) [#64](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/64)
88

9+
**Fixes**
10+
11+
- Issue fixed when the optional `selection` property was not provided to the `ListView` [#65](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/65)
12+
913
## 1.2.5
1014

1115
**Fixes**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- `TaxonomyPicker` control got added [#22](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/22) [#63](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/63) [#64](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/64)
88

9+
**Fixes**
10+
11+
- Issue fixed when the optional `selection` property was not provided to the `ListView` [#65](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/65)
12+
913
## 1.2.5
1014

1115
**Fixes**

src/controls/listView/ListView.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
6060

6161
if (!isEqual(prevProps, this.props)) {
6262
// Reset the selected items
63-
this._selection.setItems(this.props.items, true);
63+
if (this._selection) {
64+
this._selection.setItems(this.props.items, true);
65+
}
6466
// Process list view properties
6567
this._processProperties();
6668
}
@@ -353,15 +355,17 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
353355
const sortedItems = descending ? ascItems.reverse() : ascItems;
354356

355357
// Check if selection needs to be updated
356-
const selection = this._selection.getSelection();
357-
if (selection && selection.length > 0) {
358-
// Clear selection
359-
this._selection.setItems([], true);
360-
setTimeout(() => {
361-
// Find new index
362-
let idxs: number[] = selection.map(item => findIndex(sortedItems, item));
363-
idxs.forEach(idx => this._selection.setIndexSelected(idx, true, false));
364-
}, 0);
358+
if (this._selection) {
359+
const selection = this._selection.getSelection();
360+
if (selection && selection.length > 0) {
361+
// Clear selection
362+
this._selection.setItems([], true);
363+
setTimeout(() => {
364+
// Find new index
365+
let idxs: number[] = selection.map(item => findIndex(sortedItems, item));
366+
idxs.forEach(idx => this._selection.setIndexSelected(idx, true, false));
367+
}, 0);
368+
}
365369
}
366370

367371
// Return the sorted items list

0 commit comments

Comments
 (0)