Skip to content

Commit 732411c

Browse files
daKmoRMikhail Bashkirov
authored andcommitted
feat(button): use DisabledWithTabIndexMixin
1 parent e5b174e commit 732411c

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

packages/button/src/LionButton.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
import { css, html, DelegateMixin, SlotMixin } from '@lion/core';
1+
import { css, html, DelegateMixin, SlotMixin, DisabledWithTabIndexMixin } from '@lion/core';
22
import { LionLitElement } from '@lion/core/src/LionLitElement.js';
33

4-
export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
4+
export class LionButton extends DisabledWithTabIndexMixin(
5+
DelegateMixin(SlotMixin(LionLitElement)),
6+
) {
57
static get properties() {
68
return {
7-
disabled: {
8-
type: Boolean,
9-
reflect: true,
10-
},
119
role: {
1210
type: String,
1311
reflect: true,
1412
},
15-
tabindex: {
16-
type: Number,
17-
reflect: true,
18-
},
1913
};
2014
}
2115

@@ -109,13 +103,6 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
109103
];
110104
}
111105

112-
_requestUpdate(name, oldValue) {
113-
super._requestUpdate(name, oldValue);
114-
if (name === 'disabled') {
115-
this.__onDisabledChanged(oldValue);
116-
}
117-
}
118-
119106
get delegations() {
120107
return {
121108
...super.delegations,
@@ -140,9 +127,7 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
140127

141128
constructor() {
142129
super();
143-
this.disabled = false;
144130
this.role = 'button';
145-
this.tabindex = 0;
146131
}
147132

148133
connectedCallback() {
@@ -206,13 +191,4 @@ export class LionButton extends DelegateMixin(SlotMixin(LionLitElement)) {
206191
this.shadowRoot.querySelector('.click-area').click();
207192
}
208193
}
209-
210-
__onDisabledChanged() {
211-
if (this.disabled) {
212-
this.__originalTabIndex = this.tabindex;
213-
this.tabindex = -1;
214-
} else {
215-
this.tabindex = this.__originalTabIndex;
216-
}
217-
}
218194
}

0 commit comments

Comments
 (0)