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

Lion Button should not react to clicks when its disabled #2354

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ui/components/button/src/LionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const isSpaceKeyboardClickEvent = (/** @type {KeyboardEvent} */ e) => e.key ===
* - When implicit form submission should be supported on top, use LionButtonSubmit.
*/
export class LionButton extends DisabledWithTabIndexMixin(LitElement) {
static formAssociated = true;

static get properties() {
return {
active: { type: Boolean, reflect: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ export function LionButtonSuite({ klass = LionButton } = {}) {
expect(el.getAttribute('tabindex')).to.equal('0');
});

it('does not react to clicks when disabled (issue-2330)', async () => {
const clickSpy = sinon.spy();
const el = /** @type {LionButton} */ (
await fixture(html`<${tagButton} disabled @click=${clickSpy}></${tagButton}>`)
);
el.click();
expect(clickSpy).to.not.have.been.called;
});

it('has a tabindex="-1" when disabled', async () => {
const el = /** @type {LionButton} */ (
await fixture(html`<${tagButton} disabled>foo</${tagButton}>`)
Expand Down