From e0fff8756a455e1bdab201ed58f5ab2c14001ccb Mon Sep 17 00:00:00 2001 From: Jorge Date: Thu, 15 Mar 2018 15:29:32 +0000 Subject: [PATCH] Fixed crash on categories collapse. In HierarchicalTermSelector we were not assigning the promise to this.fetchRequest as componentWillUnmount expected. --- .../post-taxonomies/hierarchical-term-selector.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/editor/components/post-taxonomies/hierarchical-term-selector.js b/editor/components/post-taxonomies/hierarchical-term-selector.js index bb6e52bedcd50..32c80de9502f5 100644 --- a/editor/components/post-taxonomies/hierarchical-term-selector.js +++ b/editor/components/post-taxonomies/hierarchical-term-selector.js @@ -145,6 +145,7 @@ class HierarchicalTermSelector extends Component { ) ); this.props.speak( termAddedMessage, 'assertive' ); + this.addRequest = null; this.setState( { adding: false, formName: '', @@ -157,6 +158,7 @@ class HierarchicalTermSelector extends Component { if ( xhr.statusText === 'abort' ) { return; } + this.addRequest = null; this.setState( { adding: false, } ); @@ -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, @@ -179,6 +183,7 @@ class HierarchicalTermSelector extends Component { if ( xhr.statusText === 'abort' ) { return; } + this.fetchRequest = null; this.setState( { loading: false, } );