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

Unified Diff: chrome/browser/resources/md_bookmarks/folder_node.js

Issue 2955563002: MD Bookmarks: Initial screenreader accessibility improvements (Closed)
Patch Set: Hide the undo button when toast is closed Created 3 years, 6 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: chrome/browser/resources/md_bookmarks/folder_node.js
diff --git a/chrome/browser/resources/md_bookmarks/folder_node.js b/chrome/browser/resources/md_bookmarks/folder_node.js
index c6885cecd50d592923c7b65ad115a2d6ecbd63c3..91d0e4004adc7b66319a43a27ec6ed882698c8d3 100644
--- a/chrome/browser/resources/md_bookmarks/folder_node.js
+++ b/chrome/browser/resources/md_bookmarks/folder_node.js
@@ -40,12 +40,21 @@ Polymer({
reflectToAttribute: true,
computed: 'computeIsSelected_(itemId, selectedFolder_, searchActive_)'
},
+
+ hasChildFolder_: {
calamity 2017/06/30 06:05:18 /** @private */
tsergeant 2017/07/03 04:07:19 Done.
+ type: Boolean,
+ computed: 'computeHasChildFolder_(item_.children)',
+ },
},
listeners: {
'keydown': 'onKeydown_',
},
+ observers: [
+ 'updateAriaExpanded_(hasChildFolder_, isClosed_)',
+ ],
+
/** @override */
attached: function() {
this.watch('item_', function(state) {
@@ -135,7 +144,7 @@ Polymer({
if (xDirection == 1) {
// The right arrow opens a folder if closed and goes to the first child
// otherwise.
- if (this.hasChildFolder_()) {
+ if (this.hasChildFolder_) {
if (this.isClosed_) {
this.dispatch(
bookmarks.actions.changeFolderOpen(this.item_.id, true));
@@ -146,7 +155,7 @@ Polymer({
} else if (xDirection == -1) {
// The left arrow closes a folder if open and goes to the parent
// otherwise.
- if (this.hasChildFolder_() && !this.isClosed_) {
+ if (this.hasChildFolder_ && !this.isClosed_) {
this.dispatch(bookmarks.actions.changeFolderOpen(this.item_.id, false));
} else {
var parentFolderNode = this.getParentFolderNode_();
@@ -317,13 +326,15 @@ Polymer({
* @private
* @return {boolean}
*/
- hasChildFolder_: function() {
+ computeHasChildFolder_: function() {
return bookmarks.util.hasChildFolders(this.itemId, this.getState().nodes);
},
/** @private */
depthChanged_: function() {
this.style.setProperty('--node-depth', String(this.depth));
+ if (this.depth == -1)
+ this.$.descendants.removeAttribute('role');
},
/**
@@ -358,4 +369,18 @@ Polymer({
getTabIndex_: function() {
return this.isSelectedFolder_ ? '0' : '-1';
},
+
+ /**
+ * Sets the 'aria-expanded' accessibility on nodes which need it. Note that
+ * aria-expanded="false" is different to having the attribute be undefined.
+ * @param {boolean} hasChildFolder
+ * @param {boolean} isClosed
+ * @private
+ */
+ updateAriaExpanded_: function(hasChildFolder, isClosed) {
+ if (hasChildFolder)
+ this.getFocusTarget().setAttribute('aria-expanded', String(!isClosed));
+ else
+ this.getFocusTarget().removeAttribute('aria-expanded');
+ },
});

Powered by Google App Engine
This is Rietveld 408576698