diff --git a/projects/plugins/jetpack/extensions/blocks/map/edit.js b/projects/plugins/jetpack/extensions/blocks/map/edit.js index e5758c3475e1f..f0dbb3d370558 100644 --- a/projects/plugins/jetpack/extensions/blocks/map/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/map/edit.js @@ -1,6 +1,11 @@ import { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils'; import apiFetch from '@wordpress/api-fetch'; -import { BlockControls, InspectorControls, useBlockProps } from '@wordpress/block-editor'; +import { + BlockControls, + InspectorControls, + useBlockProps, + store as blockEditorStore, +} from '@wordpress/block-editor'; import { Button, ExternalLink, @@ -10,7 +15,7 @@ import { ResizableBox, } from '@wordpress/components'; import { compose } from '@wordpress/compose'; -import { withDispatch } from '@wordpress/data'; +import { withDispatch, useSelect } from '@wordpress/data'; import { useEffect, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { getActiveStyleName } from '../../shared/block-styles'; @@ -67,6 +72,14 @@ const MapEdit = ( { showFullscreenButton, } = attributes; + const { isPreviewMode } = useSelect( select => { + const { getSettings } = select( blockEditorStore ); + const settings = getSettings(); + return { + isPreviewMode: settings.__unstableIsPreviewMode, + }; + }, [] ); + const [ addPointVisibility, setAddPointVisibility ] = useState( false ); const [ apiState, setApiState ] = useState( API_STATE_LOADING ); const [ apiKey, setApiKey ] = useState( null ); @@ -223,7 +236,7 @@ const MapEdit = ( { let content; - if ( preview ) { + if ( preview || isPreviewMode ) { const mapStyleObject = styles.find( styleObject => styleObject.name === mapStyle ); content = (