Skip to content

Commit

Permalink
Makes sure rotateEnabled() always returns a boolean. (#1455) (patch)
Browse files Browse the repository at this point in the history
`_rotateEnabled` might not yet be initialized when calling
`rotateEnabled`, returning `undefined` in that case.

Adopting this pattern from other places such as `layerDragEnabled`.
  • Loading branch information
strfx authored Feb 15, 2024
1 parent 7f388cc commit d15ba86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions cypress/integration/rotation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Rotation', () => {

cy.window().then(({ map }) => {
const layer = map.pm.getGeomanDrawLayers()[0];
expect(layer.pm.rotateEnabled()).to.equal(false);

layer.pm.enableRotate();
expect(layer.pm.rotateEnabled()).to.equal(true);
Expand Down
2 changes: 1 addition & 1 deletion src/js/Mixins/Rotating.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const RotateMixin = {
}
},
rotateEnabled() {
return this._rotateEnabled;
return !!this._rotateEnabled;
},
// angle is clockwise (0-360)
rotateLayer(degrees) {
Expand Down

0 comments on commit d15ba86

Please sign in to comment.