Commit d4e5fdd3 authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

Focus action button instead of triggering in profile picture chooser.

This improves accessibility behavior by focusing the button that will
perform the action when the selected item is pressed. Before, this
would have deleted a user photo or taken a photo. The new behavior
moves focus to a button that is properly labeled.

Bug: 765104,767820
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I8b813a9d53c0e5b47579274253c173fc4294404f
Reviewed-on: https://chromium-review.googlesource.com/764594
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516391}
parent d70d4322
...@@ -86,6 +86,7 @@ Polymer({ ...@@ -86,6 +86,7 @@ Polymer({
listeners: { listeners: {
'discard-image': 'onDiscardImage_', 'discard-image': 'onDiscardImage_',
'image-activate': 'onImageActivate_', 'image-activate': 'onImageActivate_',
'focus-action': 'onFocusAction_',
'photo-taken': 'onPhotoTaken_', 'photo-taken': 'onPhotoTaken_',
'switch-mode': 'onSwitchMode_', 'switch-mode': 'onSwitchMode_',
}, },
...@@ -189,6 +190,11 @@ Polymer({ ...@@ -189,6 +190,11 @@ Polymer({
this.selectImage_(event.detail); this.selectImage_(event.detail);
}, },
/** Focus the action button in the picture pane. */
onFocusAction_: function() {
/** CrPicturePaneElement */ (this.$.picturePane).focusActionButton();
},
/** /**
* @param {!{detail: !{photoDataUrl: string}}} event * @param {!{detail: !{photoDataUrl: string}}} event
* @private * @private
......
...@@ -67,6 +67,7 @@ Polymer({ ...@@ -67,6 +67,7 @@ Polymer({
listeners: { listeners: {
'discard-image': 'onDiscardImage_', 'discard-image': 'onDiscardImage_',
'image-activate': 'onImageActivate_', 'image-activate': 'onImageActivate_',
'focus-action': 'onFocusAction_',
'photo-taken': 'onPhotoTaken_', 'photo-taken': 'onPhotoTaken_',
'switch-mode': 'onSwitchMode_', 'switch-mode': 'onSwitchMode_',
}, },
...@@ -202,6 +203,11 @@ Polymer({ ...@@ -202,6 +203,11 @@ Polymer({
this.selectImage_(event.detail); this.selectImage_(event.detail);
}, },
/** Focus the action button in the picture pane. */
onFocusAction_: function() {
/** CrPicturePaneElement */ (this.$.picturePane).focusActionButton();
},
/** /**
* @param {!{detail: !{photoDataUrl: string}}} event * @param {!{detail: !{photoDataUrl: string}}} event
* @private * @private
......
...@@ -84,6 +84,12 @@ Polymer({ ...@@ -84,6 +84,12 @@ Polymer({
this.stopCamera(); this.stopCamera();
}, },
/** Only focuses the button if it's not disabled. */
focusTakePhotoButton: function() {
if (this.cameraOnline_)
this.$.takePhoto.focus();
},
/** /**
* Performs photo capture from the live camera stream. A 'photo-taken' event * Performs photo capture from the live camera stream. A 'photo-taken' event
* will be fired as soon as captured photo is available, with the * will be fired as soon as captured photo is available, with the
......
...@@ -230,10 +230,15 @@ Polymer({ ...@@ -230,10 +230,15 @@ Polymer({
this.cameraSelected_ = this.cameraSelected_ =
selected.dataset.type == CrPicture.SelectionTypes.CAMERA; selected.dataset.type == CrPicture.SelectionTypes.CAMERA;
this.selectedItem = selected; this.selectedItem = selected;
if (activate && selected.dataset.type == CrPicture.SelectionTypes.OLD)
this.fire('discard-image'); if (selected.dataset.type == CrPicture.SelectionTypes.OLD ||
else if (activate || selected.dataset.type != CrPicture.SelectionTypes.FILE) selected.dataset.type == CrPicture.SelectionTypes.CAMERA) {
if (activate)
this.fire('focus-action', selected);
} else if (
activate || selected.dataset.type != CrPicture.SelectionTypes.FILE) {
this.fire('image-activate', selected); this.fire('image-activate', selected);
}
}, },
/** /**
...@@ -242,8 +247,9 @@ Polymer({ ...@@ -242,8 +247,9 @@ Polymer({
*/ */
onIronActivate_: function(event) { onIronActivate_: function(event) {
var type = event.detail.item.dataset.type; var type = event.detail.item.dataset.type;
// When clicking on the 'old' (current) image, do not activate (discard) it. // Don't change focus when activating the camera or current image via mouse.
var activate = type != CrPicture.SelectionTypes.OLD; var activate = type != CrPicture.SelectionTypes.OLD &&
type != CrPicture.SelectionTypes.CAMERA;
this.selectImage_(event.detail.item, activate); this.selectImage_(event.detail.item, activate);
}, },
......
...@@ -66,11 +66,19 @@ Polymer({ ...@@ -66,11 +66,19 @@ Polymer({
camera.takePhoto(); camera.takePhoto();
}, },
/** Tells the pane to focus the main action button. */
focusActionButton: function() {
if (this.showDiscard_())
this.$.discardImage.focus();
else if (this.cameraActive_)
this.$$('#camera').focusTakePhotoButton();
},
/** /**
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
getCameraActive_() { getCameraActive_: function() {
return this.cameraPresent && return this.cameraPresent &&
this.imageType == CrPicture.SelectionTypes.CAMERA; this.imageType == CrPicture.SelectionTypes.CAMERA;
}, },
......
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