Commit 5e0a555a authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

A11y: Add context menu when multiple bookmarks are selected.

No UI change, only behavior on which menu to show. Both menu and
selection are pre-existing UI.

Bug: 910412
Change-Id: I7335ef5b2e5675b6ff0de5bde14dc5144a4d7311
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772442
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691757}
parent 569d6adf
......@@ -412,6 +412,9 @@
<message name="IDS_BOOKMARK_MANAGER_MORE_ACTIONS_AX_LABEL" desc="Spoken text for the button in the bookmark manager which shows an action menu for a bookmark, with actions like 'Edit' or 'Delete'">
More actions for <ph name="BOOKMARK_NAME">$1<ex>Bookmark X</ex></ph>
</message>
<message name="IDS_BOOKMARK_MANAGER_MORE_ACTIONS_MULTI_AX_LABEL" desc="Spoken text for the button in the bookmark manager which shows an action menu for multiple selected bookmarks, with actions like 'Cut' or 'Delete'">
More actions for selected items
</message>
<message name="IDS_BOOKMARK_MANAGER_OPEN_DIALOG_TITLE" desc="Title of the dialog confirming whether a large number of bookmarks should be opened.">
Open selected items
</message>
......
......@@ -79,10 +79,7 @@ Polymer({
this.updateFromStore();
},
/**
* Overriden from bookmarks.MouseFocusBehavior.
* @return {!HTMLElement}
*/
/** @return {!HTMLElement} */
getFocusTarget: function() {
return this.$.container;
},
......
......@@ -107,7 +107,8 @@
id="menuButton"
tabindex="[[ironListTabIndex]]"
title="$i18n{moreActionsButtonTitle}"
aria-label$="[[getButtonAriaLabel_(item_)]]"
aria-label$="[[getButtonAriaLabel_(item_, isSelectedItem_,
isMultiSelect_)]]"
on-click="onMenuButtonClick_"
aria-haspopup="menu"></cr-icon-button>
</template>
......
......@@ -35,6 +35,9 @@ Polymer({
observer: 'onIsSelectedItemChanged_',
},
/** @private */
isMultiSelect_: Boolean,
/** @private */
isFolder_: Boolean,
......@@ -66,6 +69,7 @@ Polymer({
this.watch('item_', store => store.nodes[this.itemId]);
this.watch(
'isSelectedItem_', store => store.selection.items.has(this.itemId));
this.watch('isMultiSelect_', store => store.selection.items.size > 1);
this.updateFromStore();
},
......@@ -113,7 +117,12 @@ Polymer({
onMenuButtonClick_: function(e) {
e.stopPropagation();
e.preventDefault();
this.selectThisItem_();
// Skip selecting the item if this item is part of a multi-selected group.
if (!this.isMultiSelectMenu_()) {
this.selectThisItem_();
}
this.fire('open-command-menu', {
targetElement: e.target,
source: MenuSource.ITEM,
......@@ -251,9 +260,29 @@ Polymer({
url ? cr.icon.getFaviconForPageURL(url, false) : null;
},
/** @private */
/**
* @return {string}
* @private
*/
getButtonAriaLabel_: function() {
if (!this.item_) {
return ''; // Item hasn't loaded, skip for now.
}
if (this.isMultiSelectMenu_()) {
return loadTimeData.getStringF('moreActionsMultiButtonAxLabel');
}
return loadTimeData.getStringF(
'moreActionsButtonAxLabel', this.item_.title);
}
},
/**
* This item is part of a group selection.
* @return {boolean}
* @private
*/
isMultiSelectMenu_: function() {
return this.isSelectedItem_ && this.isMultiSelect_;
},
});
......@@ -93,6 +93,8 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
{"menuSort", IDS_BOOKMARK_MANAGER_MENU_SORT},
{"moreActionsButtonTitle", IDS_BOOKMARK_MANAGER_MORE_ACTIONS},
{"moreActionsButtonAxLabel", IDS_BOOKMARK_MANAGER_MORE_ACTIONS_AX_LABEL},
{"moreActionsMultiButtonAxLabel",
IDS_BOOKMARK_MANAGER_MORE_ACTIONS_MULTI_AX_LABEL},
{"noSearchResults", IDS_SEARCH_NO_RESULTS},
{"openDialogBody", IDS_BOOKMARK_BAR_SHOULD_OPEN_ALL},
{"openDialogConfirm", IDS_BOOKMARK_MANAGER_OPEN_DIALOG_CONFIRM},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment