@vaadin/a11y-base 24.7.0-alpha5 → 24.7.0-alpha7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/a11y-base",
|
|
3
|
-
"version": "24.7.0-
|
|
3
|
+
"version": "24.7.0-alpha7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "24.7.0-
|
|
35
|
+
"@vaadin/component-base": "24.7.0-alpha7",
|
|
36
36
|
"lit": "^3.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@vaadin/chai-plugins": "24.7.0-
|
|
39
|
+
"@vaadin/chai-plugins": "24.7.0-alpha7",
|
|
40
40
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
41
41
|
"sinon": "^18.0.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "5f48d7024caa02773aff3aa53091326a42d1eeb1"
|
|
44
44
|
}
|
|
@@ -38,4 +38,10 @@ export declare class KeyboardDirectionMixinClass {
|
|
|
38
38
|
* Focus the given item. Override this method to add custom logic.
|
|
39
39
|
*/
|
|
40
40
|
protected _focusItem(item: Element, navigating: boolean): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether the item is focusable. By default,
|
|
44
|
+
* returns true if the item is not disabled.
|
|
45
|
+
*/
|
|
46
|
+
protected _isItemFocusable(item: Element): boolean;
|
|
41
47
|
}
|
|
@@ -171,7 +171,7 @@ export const KeyboardDirectionMixin = (superclass) =>
|
|
|
171
171
|
|
|
172
172
|
const item = items[idx];
|
|
173
173
|
|
|
174
|
-
if (
|
|
174
|
+
if (this._isItemFocusable(item) && this.__isMatchingItem(item, condition)) {
|
|
175
175
|
return idx;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -189,4 +189,16 @@ export const KeyboardDirectionMixin = (superclass) =>
|
|
|
189
189
|
__isMatchingItem(item, condition) {
|
|
190
190
|
return typeof condition === 'function' ? condition(item) : true;
|
|
191
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns whether the item is focusable. By default,
|
|
195
|
+
* returns true if the item is not disabled.
|
|
196
|
+
*
|
|
197
|
+
* @param {Element} item
|
|
198
|
+
* @return {boolean}
|
|
199
|
+
* @protected
|
|
200
|
+
*/
|
|
201
|
+
_isItemFocusable(item) {
|
|
202
|
+
return !item.hasAttribute('disabled');
|
|
203
|
+
}
|
|
192
204
|
};
|
package/src/list-mixin.js
CHANGED
|
@@ -265,15 +265,6 @@ export const ListMixin = (superClass) =>
|
|
|
265
265
|
super._onKeyDown(event);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
/**
|
|
269
|
-
* @param {!Element} item
|
|
270
|
-
* @return {boolean}
|
|
271
|
-
* @protected
|
|
272
|
-
*/
|
|
273
|
-
_isItemHidden(item) {
|
|
274
|
-
return getComputedStyle(item).display === 'none';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
268
|
/**
|
|
278
269
|
* @param {number} idx
|
|
279
270
|
* @protected
|
package/src/tabindex-mixin.js
CHANGED
|
@@ -52,6 +52,10 @@ export const TabindexMixin = (superclass) =>
|
|
|
52
52
|
_disabledChanged(disabled, oldDisabled) {
|
|
53
53
|
super._disabledChanged(disabled, oldDisabled);
|
|
54
54
|
|
|
55
|
+
if (this.__shouldAllowFocusWhenDisabled()) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
if (disabled) {
|
|
56
60
|
if (this.tabindex !== undefined) {
|
|
57
61
|
this._lastTabIndex = this.tabindex;
|
|
@@ -70,9 +74,39 @@ export const TabindexMixin = (superclass) =>
|
|
|
70
74
|
* @protected
|
|
71
75
|
*/
|
|
72
76
|
_tabindexChanged(tabindex) {
|
|
77
|
+
if (this.__shouldAllowFocusWhenDisabled()) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
if (this.disabled && tabindex !== -1) {
|
|
74
82
|
this._lastTabIndex = tabindex;
|
|
75
83
|
this.tabindex = -1;
|
|
76
84
|
}
|
|
77
85
|
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Overrides the native `focus` method in order to prevent
|
|
89
|
+
* focusing the element when it is disabled. Note, setting
|
|
90
|
+
* `tabindex` to -1 does not prevent the element from being
|
|
91
|
+
* programmatically focusable.
|
|
92
|
+
*
|
|
93
|
+
* @protected
|
|
94
|
+
* @override
|
|
95
|
+
*/
|
|
96
|
+
focus() {
|
|
97
|
+
if (!this.disabled || this.__shouldAllowFocusWhenDisabled()) {
|
|
98
|
+
super.focus();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns whether the component should be focusable when disabled.
|
|
104
|
+
* Returns false by default.
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
* @return {boolean}
|
|
108
|
+
*/
|
|
109
|
+
__shouldAllowFocusWhenDisabled() {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
78
112
|
};
|