Skip to content

Commit

Permalink
Fix removing temp-layer if layer is removed while rotation (#998) (pa…
Browse files Browse the repository at this point in the history
…tch)

* Fix removing temp-layer if layer is removed while rotation

* Replace with disableRotate

* Update src/js/Mixins/Rotating.js

* Update src/js/Mixins/Rotating.js

* Update src/js/Mixins/Rotating.js

Co-authored-by: Sumit Kumar <sk@outlook.com>
  • Loading branch information
Falke-Design and codeofsumit committed Oct 10, 2021
1 parent 0648a0e commit 5dedbaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cypress/integration/rotation.spec.js
Expand Up @@ -191,4 +191,20 @@ describe('Rotation', () => {
expect(Math.ceil(layer.pm.getAngle())).to.eq(64);
});
});

it('removes hidden rotatePoly if layer is removed', () => {
cy.toolbarButton('rectangle')
.click()
.closest('.button-container')
.should('have.class', 'active');
cy.get(mapSelector).click(200, 200).click(600, 350);

cy.window().then(({ map }) => {
const layer = map.pm.getGeomanDrawLayers()[0];
layer.pm.enableRotate();
const rotatePoly = layer.pm._rotatePoly;
layer.remove();
expect(!!rotatePoly._map).to.eq(false);
});
});
});
4 changes: 4 additions & 0 deletions src/js/Mixins/Rotating.js
Expand Up @@ -168,6 +168,8 @@ const RotateMixin = {

this._rotateEnabled = true;

this._layer.on('remove', this.disableRotate, this);

this._fireRotationEnable(this._layer);
// we need to use this._layer._map because this._map can be undefined if layer was never enabled for editing before
this._fireRotationEnable(this._layer._map);
Expand All @@ -181,6 +183,8 @@ const RotateMixin = {
this._rotatePoly = undefined;
this._rotateOrgLatLng = undefined;

this._layer.off('remove', this.disableRotate, this);

this._rotateEnabled = false;

this._fireRotationDisable(this._layer);
Expand Down

0 comments on commit 5dedbaf

Please sign in to comment.