diff --git a/src/ui/map/HexGridLayer.tsx b/src/ui/map/HexGridLayer.tsx index c967939..93ad244 100644 --- a/src/ui/map/HexGridLayer.tsx +++ b/src/ui/map/HexGridLayer.tsx @@ -17,6 +17,7 @@ export function HexGridLayer() { const selectedCellId = useBlockbusterStore((s) => s.selectedCellId); const hoveredCellId = useBlockbusterStore((s) => s.hoveredCellId); const waypoints = useBlockbusterStore((s) => s.waypoints); + const drawMode = useBlockbusterStore((s) => s.drawMode); const selectCell = useBlockbusterStore((s) => s.selectCell); const hoverCell = useBlockbusterStore((s) => s.hoverCell); @@ -31,6 +32,13 @@ export function HexGridLayer() { if (!grid || !showHexGrid) return null; const waypointSet = new Set(waypoints); + // While an extra-risk draw tool is armed, taps must not select or hover a + // cell — on touch devices the click-through CSS (pointer-events: none) does + // not stop the polygon's own click, so a tap would otherwise select a cell + // instead of starting the shape. Disarming the handlers makes drawing behave + // identically on mouse and touch; Terra Draw still receives the gesture at the + // map-container level. See ExtraRiskDraw / app.css `.leaflet-drawing`. + const drawing = drawMode !== null; // Own pane (below the pie + route panes) so the stack order survives toggling // the grid off and on — Leaflet otherwise paints by DOM insertion order. @@ -51,11 +59,13 @@ export function HexGridLayer() { const isHovered = cell.id === hoveredCellId; const isWaypoint = waypointSet.has(cell.id); - const handlers: LeafletEventHandlerFnMap = { - click: () => selectCell(cell.id), - mouseover: () => hoverCell(cell.id), - mouseout: () => hoverCell(null), - }; + const handlers: LeafletEventHandlerFnMap = drawing + ? {} + : { + click: () => selectCell(cell.id), + mouseover: () => hoverCell(cell.id), + mouseout: () => hoverCell(null), + }; return ( { const draw = drawRef.current; if (!draw) return; if (drawMode) { if (!draw.enabled) draw.start(); draw.setMode(drawMode); - } else if (draw.enabled) { - draw.stop(); + map.dragging.disable(); + map.doubleClickZoom.disable(); + return () => { + map.dragging.enable(); + map.doubleClickZoom.enable(); + }; } - }, [drawMode]); + if (draw.enabled) draw.stop(); + return undefined; + }, [drawMode, map]); // While a tool is armed, flag the map container so its vector layers (hexes, // zones) and markers become click-through (see app.css). Otherwise Leaflet diff --git a/src/ui/map/extra-risk/ExtraRiskLayer.tsx b/src/ui/map/extra-risk/ExtraRiskLayer.tsx index d661b88..838d1a4 100644 --- a/src/ui/map/extra-risk/ExtraRiskLayer.tsx +++ b/src/ui/map/extra-risk/ExtraRiskLayer.tsx @@ -13,8 +13,12 @@ export function ExtraRiskLayer() { const zones = useBlockbusterStore((s) => s.zones); const selectedZoneId = useBlockbusterStore((s) => s.selectedZoneId); const activeTab = useBlockbusterStore((s) => s.activeTab); + const drawMode = useBlockbusterStore((s) => s.drawMode); const selectZone = useBlockbusterStore((s) => s.selectZone); - const interactive = activeTab === 'extra'; + // Clickable to select only on the Extra-factors tab, and never while a draw + // tool is armed — on touch a tap inside a committed zone would otherwise + // select it instead of starting the new shape (see HexGridLayer). + const interactive = activeTab === 'extra' && drawMode === null; if (zones.length === 0) return null;