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

A11y fix for "Open With" dialog

Accessibility fix for "Open With" dialog that wasn't being read by
Chromevox.

Change DefaultTaskDialog to set tabindex=-1 for dialog items, so they
can be navigated via JS focus() method, but not via TAB key.

Change cr.ui.List to issue an focus to the item when navigated via
keyboard arrow up/down.

Dialog items already have the correct text to be read, see bug for
screenshot.

Bug: 435010
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I2abc1d2d3d6cb6e78a373ccc51c79e34a0b756bd
Reviewed-on: https://chromium-review.googlesource.com/968004Reviewed-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@{#545732}
parent f8e30387
...@@ -35,6 +35,7 @@ cr.define('cr.filebrowser', function() { ...@@ -35,6 +35,7 @@ cr.define('cr.filebrowser', function() {
this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this); this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this);
// Use 'click' instead of 'change' for keyboard users. // Use 'click' instead of 'change' for keyboard users.
this.list_.addEventListener('click', this.onSelected_.bind(this)); this.list_.addEventListener('click', this.onSelected_.bind(this));
this.list_.addEventListener('change', this.onListChange_.bind(this));
this.initialFocusElement_ = this.list_; this.initialFocusElement_ = this.list_;
...@@ -71,6 +72,8 @@ cr.define('cr.filebrowser', function() { ...@@ -71,6 +72,8 @@ cr.define('cr.filebrowser', function() {
div.classList.add(item.class); div.classList.add(item.class);
result.appendChild(div); result.appendChild(div);
// A11y - make it focusable and readable.
result.setAttribute('tabindex', '-1');
cr.defineProperty(result, 'lead', cr.PropertyKind.BOOL_ATTR); cr.defineProperty(result, 'lead', cr.PropertyKind.BOOL_ATTR);
cr.defineProperty(result, 'selected', cr.PropertyKind.BOOL_ATTR); cr.defineProperty(result, 'selected', cr.PropertyKind.BOOL_ATTR);
...@@ -133,6 +136,20 @@ cr.define('cr.filebrowser', function() { ...@@ -133,6 +136,20 @@ cr.define('cr.filebrowser', function() {
this.activateItemAtIndex_(this.selectionModel_.selectedIndex); this.activateItemAtIndex_(this.selectionModel_.selectedIndex);
}; };
/**
* Called when cr.ui.List triggers a change event, which means user
* focused a new item on the list. Used here to isue .focus() on
* currently active item so ChromeVox can read it out.
* @param {!Event} event triggered by cr.ui.List.
*/
DefaultTaskDialog.prototype.onListChange_ = function(event) {
var list = event.target;
var activeItem =
list.getListItemByIndex(list.selectionModel_.selectedIndex);
if (activeItem)
activeItem.focus();
};
/** /**
* @override * @override
*/ */
......
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