From cae959359b00dc8d6aa8bc20074818ae70f696a7 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 6 Nov 2017 18:20:24 +0100 Subject: [PATCH] Metaboxes: unbind form events on unmount --- editor/components/meta-boxes/meta-boxes-area/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/editor/components/meta-boxes/meta-boxes-area/index.js b/editor/components/meta-boxes/meta-boxes-area/index.js index efcae3d9866140..cbb058fd2fb04c 100644 --- a/editor/components/meta-boxes/meta-boxes-area/index.js +++ b/editor/components/meta-boxes/meta-boxes-area/index.js @@ -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 ) { @@ -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(); } }