fix(button): using space on button should not scroll page (#531)
This commit is contained in:
parent
afdfdaa36a
commit
52aaa756a7
1 changed files with 7 additions and 0 deletions
|
|
@ -2,6 +2,8 @@ import { css, html, SlotMixin, DisabledWithTabIndexMixin, LitElement } from '@li
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
const isKeyboardClickEvent = e => e.keyCode === 32 /* space */ || e.keyCode === 13; /* enter */
|
const isKeyboardClickEvent = e => e.keyCode === 32 /* space */ || e.keyCode === 13; /* enter */
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
const isSpaceKeyboardClickEvent = e => e.keyCode === 32; /* space */
|
||||||
|
|
||||||
export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement)) {
|
export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement)) {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
|
|
@ -227,6 +229,11 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
|
||||||
if (this.active || !isKeyboardClickEvent(e)) {
|
if (this.active || !isKeyboardClickEvent(e)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSpaceKeyboardClickEvent(e)) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: In Edge & IE11, this toggling the active state to prevent bounce, does not work.
|
// FIXME: In Edge & IE11, this toggling the active state to prevent bounce, does not work.
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const keyupHandler = keyupEvent => {
|
const keyupHandler = keyupEvent => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue