From 1e01580c3579c0f26b06257edf0ee0289af6a1f1 Mon Sep 17 00:00:00 2001 From: Daniel da Silva Date: Sat, 23 Sep 2023 11:22:39 +0100 Subject: [PATCH 1/3] Fix pointer events on map controls --- app/scripts/components/common/mapbox/map-coords.tsx | 2 ++ .../components/common/mapbox/mapbox-style-override.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/scripts/components/common/mapbox/map-coords.tsx b/app/scripts/components/common/mapbox/map-coords.tsx index 524cbfbb5..9b4f8fb41 100644 --- a/app/scripts/components/common/mapbox/map-coords.tsx +++ b/app/scripts/components/common/mapbox/map-coords.tsx @@ -11,8 +11,10 @@ import { round } from '$utils/format'; const MapCoordsWrapper = styled.div` /* Large width so parent will wrap */ width: 100vw; + pointer-events: none !important; ${Button} { + pointer-events: auto; background: ${themeVal('color.base-400a')}; font-weight: ${themeVal('type.base.regular')}; font-size: 0.75rem; diff --git a/app/scripts/components/common/mapbox/mapbox-style-override.js b/app/scripts/components/common/mapbox/mapbox-style-override.js index dc48b736f..fdc4d3fb9 100644 --- a/app/scripts/components/common/mapbox/mapbox-style-override.js +++ b/app/scripts/components/common/mapbox/mapbox-style-override.js @@ -27,7 +27,14 @@ const MapboxStyleOverride = css` gap: ${variableGlsp(0.5)}; align-items: flex-start; float: none; - pointer-events: auto; + } + + .mapboxgl-ctrl { + pointer-events: none; + + > * { + pointer-events: auto; + } } .mapboxgl-ctrl { From 5ab974366ea58a09a62218961977948df3e02bf0 Mon Sep 17 00:00:00 2001 From: Daniel da Silva Date: Sat, 23 Sep 2023 12:19:46 +0100 Subject: [PATCH 2/3] Disable map coordinates control if the map is not interactive --- app/scripts/components/common/mapbox/map.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/components/common/mapbox/map.tsx b/app/scripts/components/common/mapbox/map.tsx index 89ab94886..9bb3cfa69 100644 --- a/app/scripts/components/common/mapbox/map.tsx +++ b/app/scripts/components/common/mapbox/map.tsx @@ -137,8 +137,6 @@ export function SimpleMap(props: SimpleMapProps): ReactElement { mapRef.current = mbMap; - mapRef.current.addControl(mapCoordsControl, 'bottom-left'); - if (onProjectionChange && projection) { mapRef.current.addControl(mapOptionsControl, 'top-left'); } @@ -162,6 +160,8 @@ export function SimpleMap(props: SimpleMapProps): ReactElement { // Add zoom controls without compass. if (mapOptions.interactive !== false) { + mapRef.current.addControl(mapCoordsControl, 'bottom-left'); + mbMap.addControl( new NavigationControl({ showCompass: false }), 'top-left' From 5276d175a9abc397c8fd07c2a12fb29c7859d9e3 Mon Sep 17 00:00:00 2001 From: Daniel da Silva Date: Sat, 23 Sep 2023 12:20:59 +0100 Subject: [PATCH 3/3] Fix lint errors --- .../components/common/mapbox/mapbox-style-override.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/scripts/components/common/mapbox/mapbox-style-override.js b/app/scripts/components/common/mapbox/mapbox-style-override.js index fdc4d3fb9..b1a2af140 100644 --- a/app/scripts/components/common/mapbox/mapbox-style-override.js +++ b/app/scripts/components/common/mapbox/mapbox-style-override.js @@ -30,6 +30,7 @@ const MapboxStyleOverride = css` } .mapboxgl-ctrl { + margin: 0; pointer-events: none; > * { @@ -37,10 +38,6 @@ const MapboxStyleOverride = css` } } - .mapboxgl-ctrl { - margin: 0; - } - .mapboxgl-ctrl-attrib { order: 100; padding: 0;