diff --git a/projects/plugins/jetpack/changelog/fix-map-block-selection b/projects/plugins/jetpack/changelog/fix-map-block-selection
new file mode 100644
index 0000000000000..989aae81cfcda
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/fix-map-block-selection
@@ -0,0 +1,4 @@
+Significance: patch
+Type: enhancement
+
+Map block: Allow maps on WordPress.com to be selectable.
diff --git a/projects/plugins/jetpack/extensions/blocks/map/component/mapkit.js b/projects/plugins/jetpack/extensions/blocks/map/component/mapkit.js
index 0d70b9f2a7e11..37f6a44c57cac 100644
--- a/projects/plugins/jetpack/extensions/blocks/map/component/mapkit.js
+++ b/projects/plugins/jetpack/extensions/blocks/map/component/mapkit.js
@@ -1,4 +1,12 @@
-import { Children, forwardRef, memo, useCallback, useEffect, useRef } from '@wordpress/element';
+import {
+ Children,
+ forwardRef,
+ memo,
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+} from '@wordpress/element';
import { get } from 'lodash';
import { MapkitProvider } from '../mapkit/context';
import {
@@ -45,6 +53,7 @@ const MapkitComponent = forwardRef(
return child;
}
} );
+ const [ isSelected, setIsSelected ] = useState( false );
useEffect( () => {
if ( error ) {
@@ -52,6 +61,23 @@ const MapkitComponent = forwardRef(
}
}, [ error, onError ] );
+ const handleBlockClick = () => {
+ setIsSelected( true );
+ };
+
+ useEffect( () => {
+ const handleClickOutside = event => {
+ if ( ! mapRef.current.contains( event.target ) ) {
+ setIsSelected( false );
+ }
+ };
+
+ document.addEventListener( 'mousedown', handleClickOutside );
+ return () => {
+ document.removeEventListener( 'mousedown', handleClickOutside );
+ };
+ }, [ mapRef ] );
+
return (