Skip to content

Commit

Permalink
Fix pointer events on map controls (#672)
Browse files Browse the repository at this point in the history
The fact that this element takes up the full width was causing
interaction problems. If you tried to draw on top of it, it was not
possible.
<img width="1401" alt="image"
src="https://github.com/NASA-IMPACT/veda-ui/assets/1090606/c84c1390-3251-4926-b80b-52390ee76c5b">

This PR removes pointer events from the parents, including them only on
the children.

@nerik This may need to be applied to the new map approach as well. I'd
ask that you please check if it is needed.
  • Loading branch information
nerik authored Sep 25, 2023
2 parents 6d2c485 + 5276d17 commit 77f3946
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/scripts/components/common/mapbox/map-coords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/components/common/mapbox/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ const MapboxStyleOverride = css`
gap: ${variableGlsp(0.5)};
align-items: flex-start;
float: none;
pointer-events: auto;
}
.mapboxgl-ctrl {
margin: 0;
pointer-events: none;
> * {
pointer-events: auto;
}
}
.mapboxgl-ctrl-attrib {
Expand Down

0 comments on commit 77f3946

Please sign in to comment.