Skip to content

refactor(editable-layer): restrict non-primary click gestures (#247)#669

Open
charlieforward9 wants to merge 2 commits into
masterfrom
codex/issue-247-primary-button-edits-ca55
Open

refactor(editable-layer): restrict non-primary click gestures (#247)#669
charlieforward9 wants to merge 2 commits into
masterfrom
codex/issue-247-primary-button-edits-ca55

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #247.

  • ignores middle- and right-button edit gestures at the EditableGeoJsonLayer event gateway before they reach active edit modes
  • keeps the direct DrawPolygonByDraggingMode primary-button guard for callers that exercise the mode outside the layer gateway
  • leaves map pan/context-menu behavior uncancelled for non-primary buttons
  • tracks accepted primary-button drag gestures through drag and stop events so non-primary gestures cannot add/edit features
  • adds regression coverage for global layer dispatch plus primary, middle, and right mouse buttons in drag polygon mode

Implementation plan

  1. Verify no open PR already resolves [Bug] DrawPolygonByDraggingMode should not allow drawing with middle or right mouse buttons #247.
  2. Address maintainer feedback by moving the primary-button policy to the shared edit-event dispatch path.
  3. Keep DrawPolygonByDraggingMode direct-call coverage so mode-level tests still prove the reported bug.

Validation

  • yarn
  • yarn test-node modules/editable-layers/test/editable-layers/editable-geojson-layer.spec.ts modules/editable-layers/test/edit-modes/lib/draw-polygon-by-dragging-mode.spec.ts
  • yarn test-node modules/editable-layers/test/editable-layers modules/editable-layers/test/edit-modes/lib
  • yarn lint
  • pre-commit yarn test: 164 files passed, 1383 tests passed, 9 skipped

Manual verification

No hosted preview is expected for this package-only behavior fix. To verify locally, run the editable-layers example and use any edit mode; left-button click/drag should edit, while middle/right click/drag should not trigger edit-mode handlers or cancel map/context-menu behavior.

Suggested local preview command:

yarn --cwd website start

Then open the editable-layers example route.

Residual risk

This enforces a primary-button edit policy at the layer gateway. If maintainers want configurable alternate gestures later, that should be a separate API design rather than implicit right/middle-button editing.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

Coverage

Stmts: 50.91% ▲+0.09% | Branch: 41.99% ▲+0.07% | Funcs: 49.35% ▲+0.15% | Lines: 51.05% ▲+0.10%

Test Files 164 passed (164)

@charlieforward9 charlieforward9 marked this pull request as ready for review June 30, 2026 02:05

@charlieforward9 charlieforward9 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've worked with this before - the smarter direction is probably to make a global edit gesture control. left click, right click etc.

@charlieforward9

Copy link
Copy Markdown
Member Author

Addressed the global gesture-control feedback in c33984b: non-primary click/double-click/start-drag events are now filtered at the EditableGeoJsonLayer dispatch point, and drag/stop only continue for primary-button drag sequences. I kept the DrawPolygonByDraggingMode guard as direct-mode protection and added layer-level regression coverage.

@charlieforward9

Copy link
Copy Markdown
Member Author

@AnJ-K let me know if this works as you expect

@charlieforward9 charlieforward9 changed the title Fix drag polygon mouse button handling (#247) refactor(editable-layer): restrict non-primary click gestures (#247) Jun 30, 2026
@charlieforward9 charlieforward9 self-assigned this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex editable-layers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DrawPolygonByDraggingMode should not allow drawing with middle or right mouse buttons

1 participant