Commit a69328e2 authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

wallpaper: Fix image grid event listener

When |this.thumbnail_| is defined, the early return prevented the event
listeners from being added so the Wallpaper app wouldn't register
pressing 'Enter'

Fixed: 1032525
Change-Id: I8debd93242ffbab3981988cdd25105483ec4fd66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463709Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816723}
parent 7d1210a4
...@@ -84,6 +84,16 @@ cr.define('wallpapers', function() { ...@@ -84,6 +84,16 @@ cr.define('wallpapers', function() {
return; return;
} }
this.setAttribute('aria-label', this.dataItem.ariaLabel);
this.tabIndex = 0;
this.addEventListener('keypress', e => {
if (e.keyCode == 13)
this.parentNode.selectedItem = this.dataItem;
});
this.addEventListener('mousedown', e => {
e.preventDefault();
});
if (this.thumbnail_) { if (this.thumbnail_) {
this.appendChild(this.thumbnail_); this.appendChild(this.thumbnail_);
this.callback_(this.dataModelId_, this.dataItem.wallpaperId); this.callback_(this.dataModelId_, this.dataItem.wallpaperId);
...@@ -94,15 +104,6 @@ cr.define('wallpapers', function() { ...@@ -94,15 +104,6 @@ cr.define('wallpapers', function() {
// Do not show the image until |cropImageToFitGrid_| is done. // Do not show the image until |cropImageToFitGrid_| is done.
imageEl.style.visibility = 'hidden'; imageEl.style.visibility = 'hidden';
imageEl.setAttribute('aria-hidden', 'true'); imageEl.setAttribute('aria-hidden', 'true');
this.setAttribute('aria-label', this.dataItem.ariaLabel);
this.tabIndex = 0;
this.addEventListener('keypress', e => {
if (e.keyCode == 13)
this.parentNode.selectedItem = this.dataItem;
});
this.addEventListener('mousedown', e => {
e.preventDefault();
});
imageEl.classList.add('thumbnail'); imageEl.classList.add('thumbnail');
cr.defineProperty(imageEl, 'offline', cr.PropertyKind.BOOL_ATTR); cr.defineProperty(imageEl, 'offline', cr.PropertyKind.BOOL_ATTR);
......
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