Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js

Issue 2715763002: MD-Settings A11y: Disable radio list if all options are disabled. (Closed)
Patch Set: fix closure Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
index bb0ed59e2e21ff20d5f661090b23079d7bca2f0c..e1d4feafee7b69ac367eb2ea191a6cd1785a6c5e 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
@@ -25,12 +25,18 @@
*/
attrForItemTitle: {
type: String
+ },
+
+ disabled: {
+ type: Boolean,
+ value: false,
+ reflectToAttribute: true,
+ observer: '_disableTabindex',
}
},
hostAttributes: {
'role': 'menu',
- 'tabindex': '0'
},
observers: [
@@ -83,7 +89,11 @@
var selectedItem = this.multi ? (this.selectedItems && this.selectedItems[0]) : this.selectedItem;
this.items.forEach(function(item) {
- item.setAttribute('tabindex', item === selectedItem ? '0' : '-1');
+ // Don't enable tab index if an item is disabled, even if it's selected.
+ if (item === selectedItem && !selectedItem.hasAttribute('disabled') && !this.disabled)
+ item.setAttribute('tabindex', 0);
+ else
+ item.removeAttribute('tabindex');
}, this);
},
@@ -194,8 +204,8 @@
* applicable.
*/
_focusedItemChanged: function(focusedItem, old) {
- old && old.setAttribute('tabindex', '-1');
- if (focusedItem) {
+ old && old.removeAttribute('tabindex');
+ if (focusedItem && !focusedItem.hasAttribute('disabled') && !this.disabled) {
focusedItem.setAttribute('tabindex', '0');
focusedItem.focus();
}
@@ -220,16 +230,16 @@
* @param {CustomEvent} event A key combination event.
*/
_onShiftTabDown: function(event) {
- var oldTabIndex = this.getAttribute('tabindex');
+ var couldTab = this.getAttribute('tabindex') == 0;
Polymer.IronMenuBehaviorImpl._shiftTabPressed = true;
this._setFocusedItem(null);
- this.setAttribute('tabindex', '-1');
+ this._disableTabindex(true);
this.async(function() {
- this.setAttribute('tabindex', oldTabIndex);
+ this._disableTabindex(!couldTab);
Dan Beam 2017/03/17 23:58:53 indent off
hcarmona 2017/03/18 01:05:07 Done.
Polymer.IronMenuBehaviorImpl._shiftTabPressed = false;
// NOTE(cdata): polymer/polymer#1305
}, 1);
@@ -319,6 +329,17 @@
_activateHandler: function(event) {
Polymer.IronSelectableBehavior._activateHandler.call(this, event);
event.stopPropagation();
+ },
+
+ /**
+ * Updates this element's tab index when it's enabled/disabled.
+ * @param {boolean} disabled
+ */
+ _disableTabindex: function(disabled) {
+ if (disabled)
+ this.removeAttribute('tabindex'); // No tabindex means not tab-able or select-able.
+ else
+ this.setAttribute('tabindex', 0); // tabindex of 0 means tab-able.
}
};
@@ -329,4 +350,4 @@
Polymer.IronMultiSelectableBehavior,
Polymer.IronA11yKeysBehavior,
Polymer.IronMenuBehaviorImpl
- ];
+ ];

Powered by Google App Engine
This is Rietveld 408576698