diff --git a/core/common/assets/js/views/modal/header.js b/core/common/assets/js/views/modal/header.js index 5fea09cca457..d41b0d898ae0 100644 --- a/core/common/assets/js/views/modal/header.js +++ b/core/common/assets/js/views/modal/header.js @@ -36,25 +36,8 @@ export default class extends Marionette.LayoutView { onCloseModalClick() { this._parent._parent._parent.hideModal(); - if ( this.isFloatingButtonLibraryClose() ) { - $e.internal( 'document/save/set-is-modified', { status: false } ); - window.location.href = elementor.config.admin_floating_button_admin_url; - } - } + const customEvent = new CustomEvent( 'core/modal/close' ); - isFloatingButtonLibraryClose() { - return window.elementor && elementor.config?.admin_floating_button_admin_url && - 'floating-buttons' === elementor.config?.document?.type && - ( - this.$el - .closest( '.dialog-lightbox-widget-content' ) - .find( '.elementor-template-library-template-floating_button' ).length || - this.$el - .closest( '.dialog-lightbox-widget-content' ) - .find( '#elementor-template-library-preview' ).length || - this.$el - .closest( '.dialog-lightbox-widget-content' ) - .find( '#elementor-template-library-templates-empty' ).length - ); + window.dispatchEvent( customEvent ); } } diff --git a/modules/floating-buttons/assets/js/floating-buttons/editor/module.js b/modules/floating-buttons/assets/js/floating-buttons/editor/module.js index 833e64ac1909..6a6723964411 100644 --- a/modules/floating-buttons/assets/js/floating-buttons/editor/module.js +++ b/modules/floating-buttons/assets/js/floating-buttons/editor/module.js @@ -4,6 +4,11 @@ class FloatingButtonsLibraryModule extends elementorModules.editor.utils.Module onElementorLoaded() { this.component = $e.components.register( new Component( { manager: this } ) ); elementor.channels.editor.on( 'section:activated', this.hideAdvancedTab.bind( this ) ); + window.addEventListener( 'core/modal/close', ( ) => { + if ( this.isFloatingButtonDocument() ) { + window.location.href = elementor.config.admin_floating_button_admin_url; + } + } ); } hideAdvancedTab( sectionName, editor ) {