Skip to content

Commit

Permalink
DetailsList: fix exception in DetailsRow when selection is undefined. (
Browse files Browse the repository at this point in the history
…microsoft#14088)

* fix exception with selection is undefined

* Change files
  • Loading branch information
xugao committed Jul 20, 2020
1 parent 4a6bdec commit 3a9feb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "DetailsList: fix exception in DetailsRow when selection is undefined.",
"packageName": "office-ui-fabric-react",
"email": "xgao@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-07-17T16:23:46.317Z"
}
Expand Up @@ -74,7 +74,7 @@ export class DetailsRowBase extends React.Component<IDetailsRowBaseProps, IDetai
}

public componentDidMount(): void {
const { dragDropHelper } = this.props;
const { dragDropHelper, selection, item, onDidMount } = this.props;

if (dragDropHelper) {
this._dragDropSubscription = dragDropHelper.subscribe(
Expand All @@ -84,12 +84,14 @@ export class DetailsRowBase extends React.Component<IDetailsRowBaseProps, IDetai
);
}

this._events.on(this.props.selection, SELECTION_CHANGE, this._onSelectionChanged);
if (selection) {
this._events.on(selection, SELECTION_CHANGE, this._onSelectionChanged);
}

if (this.props.onDidMount && this.props.item) {
if (onDidMount && item) {
// If the item appears later, we should wait for it before calling this method.
this._onDidMountCalled = true;
this.props.onDidMount(this);
onDidMount(this);
}
}

Expand Down

0 comments on commit 3a9feb3

Please sign in to comment.