Skip to content

Commit

Permalink
Fix expand/collapse for grouping in DetailsList (#15284)
Browse files Browse the repository at this point in the history
* Ensure GroupedList version is invalidated when parent list is invalidated

* Update API signatures

* Change files
  • Loading branch information
ThomasMichon authored Sep 28, 2020
1 parent c773138 commit 371d5ed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "minor",
"comment": "Ensure GroupedList version is invalidated when parent list is invalidated",
"packageName": "office-ui-fabric-react",
"email": "tmichon@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-09-28T20:15:08.995Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5061,6 +5061,8 @@ export interface IGroupedListState {
// (undocumented)
lastSelectionMode?: SelectionMode;
// (undocumented)
listProps?: IGroupedListProps['listProps'];
// (undocumented)
version: {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const { rowHeight: ROW_HEIGHT, compactRowHeight: COMPACT_ROW_HEIGHT } = DEFAULT_
export interface IGroupedListState {
lastSelectionMode?: SelectionMode;
groups?: IGroup[];
listProps?: IGroupedListProps['listProps'];
version: {};
}

Expand All @@ -46,18 +47,21 @@ export class GroupedListBase extends React.Component<IGroupedListProps, IGrouped
): IGroupedListState {
let nextState = previousState;

const { listProps: { version = undefined } = {} } = nextProps;

if (version) {
nextState = {
...nextState,
version,
};
}

const { groups, selectionMode, compact } = nextProps;
let shouldForceUpdates = false;

nextState = {
...previousState,
listProps: nextProps.listProps,
};

const nextVersion = nextProps.listProps && nextProps.listProps.version;
const version = previousState.listProps && previousState.listProps.version;

if (nextVersion !== version) {
shouldForceUpdates = true;
}

if (nextProps.groups !== groups) {
nextState = {
...nextState,
Expand Down Expand Up @@ -90,6 +94,7 @@ export class GroupedListBase extends React.Component<IGroupedListProps, IGrouped

this.state = {
groups: props.groups,
listProps: props.listProps,
version,
};
}
Expand Down

0 comments on commit 371d5ed

Please sign in to comment.