Skip to content

Commit

Permalink
Metaboxes: unbind form events on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 13, 2017
1 parent e7cf969 commit cae9593
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions editor/components/meta-boxes/meta-boxes-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class MetaBoxesArea extends Component {

componentWillUnmout() {
this.mounted = false;
this.unbindFormEvents();
}

unbindFormEvents() {
if ( this.form ) {
this.form.removeEventListener( 'change', this.checkState );
this.form.removeEventListener( 'input', this.checkState );
}
}

componentWillReceiveProps( nextProps ) {
Expand All @@ -57,6 +65,7 @@ class MetaBoxesArea extends Component {
};
const request = window.fetch( addQueryArgs( window._wpMetaBoxUrl, { meta_box: location } ), fetchOptions );
this.onMetaboxResponse( request, false );
this.unbindFormEvents();
}
}

Expand Down

0 comments on commit cae9593

Please sign in to comment.