Skip to content

Commit

Permalink
Fixed crash on categories collapse. (#5640)
Browse files Browse the repository at this point in the history
 In HierarchicalTermSelector we were not assigning the promise to this.fetchRequest as componentWillUnmount expected.
  • Loading branch information
jorgefilipecosta committed Mar 15, 2018
1 parent e4d58ec commit 41f7feb
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -145,6 +145,7 @@ class HierarchicalTermSelector extends Component {
)
);
this.props.speak( termAddedMessage, 'assertive' );
this.addRequest = null;
this.setState( {
adding: false,
formName: '',
Expand All @@ -157,6 +158,7 @@ class HierarchicalTermSelector extends Component {
if ( xhr.statusText === 'abort' ) {
return;
}
this.addRequest = null;
this.setState( {
adding: false,
} );
Expand All @@ -165,10 +167,12 @@ class HierarchicalTermSelector extends Component {

componentDidMount() {
const basePath = wp.api.getTaxonomyRoute( this.props.slug );
this.fetchRequest = wp.apiRequest( { path: `/wp/v2/${ basePath }?${ stringify( DEFAULT_QUERY ) }` } ).then(
this.fetchRequest = wp.apiRequest( { path: `/wp/v2/${ basePath }?${ stringify( DEFAULT_QUERY ) }` } );
this.fetchRequest.then(
( terms ) => { // resolve
const availableTermsTree = buildTermsTree( terms );

this.fetchRequest = null;
this.setState( {
loading: false,
availableTermsTree,
Expand All @@ -179,6 +183,7 @@ class HierarchicalTermSelector extends Component {
if ( xhr.statusText === 'abort' ) {
return;
}
this.fetchRequest = null;
this.setState( {
loading: false,
} );
Expand Down

0 comments on commit 41f7feb

Please sign in to comment.