Skip to content

Commit

Permalink
Enable disabled button incl. functions (#1165) (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design committed May 20, 2022
1 parent 441b17c commit 95a6f5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cypress/integration/toolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,28 @@ describe('Testing the Toolbar', () => {
.should('have.not.class', 'active');
});
});

it('Enable disabled button', () => {
let eventFired = '';
cy.window().then(({ map }) => {
map.on('pm:buttonclick', ({ btnName }) => {
eventFired = btnName;
});
map.pm.Toolbar.setButtonDisabled('drawPolygon', true);
});
cy.toolbarButton('polygon')
.click()
.then(() => {
expect(eventFired).to.equal('');
});

cy.window().then(({ map }) => {
map.pm.Toolbar.setButtonDisabled('drawPolygon', false);
});
cy.toolbarButton('polygon')
.click()
.then(() => {
expect(eventFired).to.equal('drawPolygon');
});
});
});
2 changes: 2 additions & 0 deletions src/js/Toolbar/L.Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ const PMButton = L.Control.extend({
} else {
L.DomUtil.removeClass(button, className);
button.setAttribute('aria-disabled', 'false');
L.DomEvent.on(button, 'click', this._triggerClick, this);
L.DomEvent.on(button, 'click', this._onBtnClick, this);
}
},
});
Expand Down

0 comments on commit 95a6f5b

Please sign in to comment.