Fixes and modifications
This commit is contained in:
@ -4,7 +4,7 @@ Copyright (c) 2022 trading_peter
|
||||
This program is available under Apache License Version 2.0
|
||||
*/
|
||||
|
||||
export const ControlState = function(superClass) {
|
||||
export const ControlState = function (superClass) {
|
||||
return class extends superClass {
|
||||
static get properties() {
|
||||
return {
|
||||
@ -20,10 +20,21 @@ export const ControlState = function(superClass) {
|
||||
|
||||
firstUpdated() {
|
||||
super.firstUpdated();
|
||||
if (!this.hasAttribute('tabindex')) {
|
||||
this.setAttribute('tabindex', '0');
|
||||
}
|
||||
this.addEventListener('focus', this._boundFocus, true);
|
||||
this.addEventListener('blur', this._boundFocus, true);
|
||||
}
|
||||
|
||||
shouldUpdate(changes) {
|
||||
if (changes.has('disabled')) {
|
||||
this._disabledChanged(this.disabled);
|
||||
}
|
||||
|
||||
return super.shouldUpdate(changes);
|
||||
}
|
||||
|
||||
_focusHandler(e) {
|
||||
this.focused = e.type === 'focus';
|
||||
}
|
||||
@ -38,7 +49,7 @@ export const ControlState = function(superClass) {
|
||||
// leaving `-1` hides shadow root children from the tab order.
|
||||
this._prevTabIndex = this.getAttribute('tabindex');
|
||||
this.focused = false;
|
||||
this.tabIndex = -1;
|
||||
this.setAttribute('tabIndex', '-1');
|
||||
this.blur();
|
||||
} else if (this._prevTabIndex !== undefined) {
|
||||
if (this._prevTabIndex === null) {
|
||||
@ -49,4 +60,4 @@ export const ControlState = function(superClass) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user