Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Expand All Fails After Adding Multiple Pages #1175

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PersonaBarPageTreeviewInteractor extends Component {
this.init();
}

static getDerivedStateFromProps(props) {
static getDerivedStateFromProps(props, state) {
let setTreeViewExpanded = null;
let pageList = null;
const {
Expand Down Expand Up @@ -72,12 +72,21 @@ class PersonaBarPageTreeviewInteractor extends Component {
}
}, pageListCopy);

return {
const newState = {
rootLoaded: true,
isTreeviewExpanded: setTreeViewExpanded,
initialCollapse: !setTreeViewExpanded,
pageList: pageList || pageListCopy
};

const prevPageListCount = (state.pageList || []).length;
const newPageListCount = (newState.pageList || []).length;

if (prevPageListCount !== newPageListCount) {
return { ...newState, isChildLoaded: false };
}

return newState;
}

componentDidUpdate() {
Expand Down