Commit ac1e8d23 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Change open button to open the list when displayed as a combobox

Change the open button when it's displayed as a combobox to open the
options list instead of opening the file when there are more options.

Open button is only displayed as a combobox when there are more than
one application for the selected file, otherwise it's displayed as
a regular button.

This change of behavior is to make the open button (as combobox)
accessible via keyboard and screen reader (Chromevox).

IMPORTANT: This is a change of behavior, but this seems more consistent
since the UI displays the button as a combo, it's expected that enter
key or click open the combo list, instead of triggering the "open"
button which is open with default app. Users already have option to
use enter key to open the file without the "open menu".

Test: browser_test
Bug: 793723
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I8dab527805cb687103882e1b650b857fd5fb876c
Reviewed-on: https://chromium-review.googlesource.com/970048Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarSasha Morrissey <sashab@chromium.org>
Commit-Queue: Luciano Pacheco (SYD) <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546722}
parent 53cdcfb5
...@@ -144,10 +144,20 @@ cr.define('cr.ui', function() { ...@@ -144,10 +144,20 @@ cr.define('cr.ui', function() {
this.dispatchSelectEvent(event.target.data); this.dispatchSelectEvent(event.target.data);
}, },
handleButtonClick_: function() { handleButtonClick_: function(event) {
this.paperRipple_.simulatedRipple(); if (this.multiple) {
this.blur(); // When there are multiple choices just show/hide menu.
this.dispatchSelectEvent(this.defaultItem_); if (this.isMenuShown()) {
this.hideMenu();
} else {
this.showMenu(true);
}
} else {
// When there is only 1 choice, just dispatch to open.
this.paperRipple_.simulatedRipple();
this.blur();
this.dispatchSelectEvent(this.defaultItem_);
}
}, },
handleMenuShow_: function() { handleMenuShow_: function() {
......
...@@ -185,17 +185,30 @@ function defaultTaskDialog(expectedTaskId, windowId) { ...@@ -185,17 +185,30 @@ function defaultTaskDialog(expectedTaskId, windowId) {
}); });
// Execute the new default task. // Execute the new default task.
var taskButtonClicked = dialogHiddenPromise. var taskButtonClicked =
then(function() { dialogHiddenPromise
return remoteCall.callRemoteTestUtil( .then(function() {
'fakeEvent', windowId, ['#tasks', 'click']); // Click on "Open ▼" button.
}). remoteCall.callRemoteTestUtil(
then(function(result) { 'fakeMouseClick', windowId, ['#tasks']);
chrome.test.assertTrue(result); // Wait for dropdown menu to show.
}); return remoteCall.waitForElement(
windowId, '#tasks-menu cr-menu-item');
})
.then(function(result) {
// Click on first menu item.
remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId,
['#tasks-menu cr-menu-item:nth-child(1)']);
// Wait dropdown menu to hide.
return remoteCall.waitForElement(windowId, '#tasks-menu[hidden]');
})
.then(function(result) {
chrome.test.assertTrue(!!result);
});
// Check the executed tasks. // Check the executed tasks.
return dialogHiddenPromise.then(function() { return taskButtonClicked.then(function() {
return remoteCall.waitUntilTaskExecutes(windowId, expectedTaskId); return remoteCall.waitUntilTaskExecutes(windowId, expectedTaskId);
}); });
} }
...@@ -251,4 +264,4 @@ testcase.genericAndNonGenericTasksAreMixed = function() { ...@@ -251,4 +264,4 @@ testcase.genericAndNonGenericTasksAreMixed = function() {
testPromise(setupTaskTest(RootPath.DOWNLOADS, tasks).then( testPromise(setupTaskTest(RootPath.DOWNLOADS, tasks).then(
executeDefaultTask.bind(null, 'dummytaskid-2|open-with'))); executeDefaultTask.bind(null, 'dummytaskid-2|open-with')));
} };
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