Skip to content

fix: allow drawing extra-risk zones on touch tablets#30

Open
IanMayo wants to merge 2 commits into
mainfrom
claude/tablet-risk-area-drawing-HzSDW
Open

fix: allow drawing extra-risk zones on touch tablets#30
IanMayo wants to merge 2 commits into
mainfrom
claude/tablet-risk-area-drawing-HzSDW

Conversation

@IanMayo

@IanMayo IanMayo commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Problem

On a touch tablet you couldn't draw extra-risk zones. Arming a tool (e.g. Rectangle) highlights its button, but tapping the map selected a hex cell instead of starting the shape.

Cause

Drawing relied on the .leaflet-drawing CSS class making hex polygons and markers click-through via pointer-events: none so taps fall through to the Terra Draw layer:

.leaflet-drawing .leaflet-pane path,
.leaflet-drawing .leaflet-marker-icon { pointer-events: none !important; }

That's a mouse-oriented trick. On a touch tablet the tap still reaches each hex polygon's own Leaflet click handler (selectCell in HexGridLayer), so the cell gets selected and the draw gesture never starts. Drawing was effectively desktop-only.

Fix

Gate the interactive handlers on drawMode rather than relying on the CSS:

  • HexGridLayer — while a draw tool is armed, bind no click/mouseover/mouseout handlers, so a tap can never select or hover a cell.
  • ExtraRiskLayer — committed zones are interactive only when no tool is armed, so a tap inside an existing zone can't steal the gesture either.

Terra Draw still listens at the map-container level, so it receives the gesture regardless. Behaviour is now identical on mouse and touch. The existing .leaflet-drawing CSS is left in place as belt-and-braces for markers.

Verification

npm run typecheck, npm run lint, npm run test:run (95 tests) and npm run build all pass.

⚠️ Note: this fixes the cell-selection symptom (verified by code inspection), but I couldn't drive a real tablet from the build environment — please confirm the actual rectangle/circle/polygon draw gesture works on your device.

https://claude.ai/code/session_015edVHaDT2Y4hfMoS6tM9mn


Generated by Claude Code

Drawing extra-risk zones relied on the `.leaflet-drawing` CSS making hex
polygons and markers click-through via `pointer-events: none`. That works
with a mouse, but on touch tablets the tap still reaches the hex polygon's
own Leaflet click handler, so a tap selected a cell instead of starting the
shape — drawing was effectively desktop-only.

Gate the interactive handlers on `drawMode` instead of relying on the CSS:
- HexGridLayer: bind no click/hover handlers while a draw tool is armed.
- ExtraRiskLayer: committed zones are interactive only when no tool is armed,
  so a tap inside an existing zone can't steal the gesture either.

Terra Draw still receives the gesture at the map-container level, so the
behaviour is now identical on mouse and touch.
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://DeepBlueCLtd.github.io/blockbuster/pr-preview/pr-30/

Built to branch gh-pages at 2026-06-04 05:34 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

After the previous fix a tap no longer selected a cell, but dragging to
draw a rectangle/circle just panned the map. Terra Draw's rectangle and
circle modes default to the `click-move` interaction, where a drag is not a
draw gesture at all, so Leaflet's drag handler consumed it as a pan.

- Set `drawInteraction: 'click-move-or-drag'` on the rectangle and circle
  modes so a single drag draws the shape (Terra Draw disables map dragging
  for the duration of that drag via the adapter's setDraggability), while two
  taps still work.
- While any tool is armed, also disable Leaflet's map dragging and
  double-click zoom so the first gesture and the two-tap path aren't hijacked
  by a pan or a double-tap zoom; the effect cleanup re-enables them on
  disarm/unmount.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants