Skip to content

Improve polygon vertex dragging responsiveness in edit mode#38

Merged
AhmedFatthy1040 merged 1 commit intoAhmedFatthy1040:mainfrom
justFadel19:fix/polygon-edit-drag-responsive
Jun 10, 2025
Merged

Improve polygon vertex dragging responsiveness in edit mode#38
AhmedFatthy1040 merged 1 commit intoAhmedFatthy1040:mainfrom
justFadel19:fix/polygon-edit-drag-responsive

Conversation

@justFadel19
Copy link
Collaborator

This pull request includes a fix in the CanvasManager class within web/js/canvas.js. The change ensures that vertex dragging is properly handled in edit mode when interacting with polygons.

Fix for edit mode behavior:

  • Added logic to check for a vertex under the mouse when in edit mode and editing a polygon. If a vertex is found, the dragging operation starts, and normal actions are bypassed. This improves the user experience by prioritizing vertex manipulation during polygon editing.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds logic to prioritize polygon vertex dragging when in edit mode, ensuring that clicks on vertices initiate drag operations instead of triggering standard actions.

  • Intercepts left-clicks in edit mode to check for and start vertex drags
  • Bypasses normal click handling when a vertex drag begins
  • Adjusts method closing braces and indentation around handleMouseMove
Comments suppressed due to low confidence (3)

web/js/canvas.js:561

  • These console.log statements appear to be leftover debug logs. Consider removing them or using a dedicated debug-level logger so production output remains clean.
console.log('Is editing polygon:', this.isEditingPolygon);

web/js/canvas.js:585

  • The closing brace and handleMouseMove declaration are merged together, impacting readability. Please split and indent properly so each block and method signature stands on its own line.
}    }    handleMouseMove(e) {

web/js/canvas.js:564

  • The new vertex drag logic isn't covered by existing tests. Consider adding unit or integration tests for getVertexAtPoint and startVertexDrag in edit mode to prevent regressions.
// --- FIX: Always check for vertex under mouse in edit mode ---

e.button === 0 &&
this.editModeActive &&
this.isEditingPolygon &&
this.editingAnnotationId
Copy link

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

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

Using a truthiness check on editingAnnotationId will skip IDs equal to 0. Use an explicit null/undefined check (e.g., this.editingAnnotationId != null) to handle all valid numeric IDs.

Suggested change
this.editingAnnotationId
this.editingAnnotationId != null

Copilot uses AI. Check for mistakes.
Copy link
Owner

@AhmedFatthy1040 AhmedFatthy1040 left a comment

Choose a reason for hiding this comment

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

LGTM

@AhmedFatthy1040 AhmedFatthy1040 merged commit d8ab813 into AhmedFatthy1040:main Jun 10, 2025
2 of 3 checks passed
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