diff --git a/apps/full-site-editing/full-site-editing-plugin/full-site-editing/plugins/close-button-override/index.js b/apps/full-site-editing/full-site-editing-plugin/full-site-editing/plugins/close-button-override/index.js index 9b46d58ecb4dc..781e697d757fe 100644 --- a/apps/full-site-editing/full-site-editing-plugin/full-site-editing/plugins/close-button-override/index.js +++ b/apps/full-site-editing/full-site-editing-plugin/full-site-editing/plugins/close-button-override/index.js @@ -1,5 +1,4 @@ /* global fullSiteEditing */ -/* global calypsoifyGutenberg */ /** * External dependencies @@ -66,6 +65,13 @@ domReady( () => { // These should go here so that they have any updates that happened while querying for the selector. let { closeButtonLabel, closeButtonUrl } = fullSiteEditing; + /** + * We have to reference calypsoifyGutenberg off of the window object + * directly to handle the case where it is undefined. Otherwise, the + * variable declariation itself won't exist, causing a runtime error. + */ + const { calypsoifyGutenberg } = window; + // Use wpcom close button/url if they exist. if ( calypsoifyGutenberg && calypsoifyGutenberg.closeUrl ) { closeButtonUrl = calypsoifyGutenberg.closeUrl;