Skip to content

Commit

Permalink
fix(button): click on mobile phones in Polymer < 2.8.0 (fixes #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Bashkirov committed Jul 11, 2019
1 parent f6c5615 commit 604a4d4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/button/src/LionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {

__clickDelegationHandler(e) {
e.stopPropagation(); // prevent click on the fake element and cause click on the native button
this.$$slot('_button').click();
this.__dispatchClickOnNativeButton();
}

__setupDelegation() {
Expand All @@ -181,10 +181,16 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
if (e.keyCode === 32 /* space */ || e.keyCode === 13 /* enter */) {
e.preventDefault();
this.shadowRoot.querySelector('.btn').removeAttribute('active');
this.$$slot('_button').click();
this.__dispatchClickOnNativeButton();
}
}

__dispatchClickOnNativeButton() {
this.$$slot('_button').dispatchEvent(
new MouseEvent('click', { bubbles: true, composed: true }),
);
}

__onDisabledChanged() {
if (this.disabled) {
this.__originalTabIndex = this.tabindex;
Expand Down

0 comments on commit 604a4d4

Please sign in to comment.