Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finishOn dblclick bug #632

Merged
merged 1 commit into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions cypress/integration/polygon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,27 @@ describe('Draw & Edit Poly', () => {
cy.toolbarButton('edit').click();
});

it('create vertex when dblclick', () => {
cy.window().then(({ map }) => {
map.pm.enableDraw('Polygon', {
allowSelfIntersection: false,
finishOn: 'dblclick',
});
});

cy.get(mapSelector)
.click(90, 250)
.click(100, 50)
.click(150, 50)
.dblclick(150, 150);

cy.toolbarButton('edit').click();

cy.hasVertexMarkers(4);

cy.toolbarButton('edit').click();
});

it('prevent creation while self intersection', () => {

cy.window().then(({ map }) => {
Expand Down
5 changes: 0 additions & 5 deletions src/js/Draw/L.PM.Draw.Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ Draw.Polygon = Draw.Line.extend({
return;
}

// create the leaflet shape and add it to the map
if (e && e.type === 'dblclick') {
// Leaflet creates an extra node with double click
coords.splice(coords.length - 1, 1);
}
const polygonLayer = L.polygon(coords, this.options.pathOptions).addTo(
this._map
);
Expand Down