Commit a9bb4c80 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Settings] Fix clicks on "Learn more" links

When "Learn more" links are displayed on top of a clickable row, they
had two potential click events: opening the URL in a browser tab as well
as any other custom click handler. In the case of the Android apps link,
clicking "Learn more" would cause the URL to open as well as navigating
to the Android apps section.

This CL fixes this by preventing propagation of the click event.

Bug: b/147082644
Change-Id: If7063e451d6eca5abadd0345157d6f4d9b46af04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2113392Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752302}
parent 49a9dbf8
...@@ -36,8 +36,8 @@ Polymer({ ...@@ -36,8 +36,8 @@ Polymer({
*/ */
linkUrl: { linkUrl: {
type: String, type: String,
value: '' value: '',
} },
}, },
/** /**
...@@ -86,13 +86,32 @@ Polymer({ ...@@ -86,13 +86,32 @@ Polymer({
assert(anchorTags.length == 1, assert(anchorTags.length == 1,
'settings-localized-link should contain exactly one anchor tag'); 'settings-localized-link should contain exactly one anchor tag');
anchorTags[0].setAttribute('aria-labelledby', ariaLabelledByIds.join(' ')); const anchorTag = anchorTags[0];
anchorTag.setAttribute('aria-labelledby', ariaLabelledByIds.join(' '));
if (linkUrl != '') { if (linkUrl != '') {
anchorTags[0].href = linkUrl; anchorTag.href = linkUrl;
anchorTags[0].target = '_blank'; anchorTag.target = '_blank';
} }
return tempEl.innerHTML; return tempEl.innerHTML;
} },
/** @override */
attached() {
const anchorTag = this.$$('a');
if (anchorTag) {
anchorTag.addEventListener('click', this.onAnchorTagClick_.bind(this));
}
},
/**
* @param {!Event} event
* @private
*/
onAnchorTagClick_(event) {
// Stop propagation of the event, since it has already been handled by
// opening the link.
event.stopPropagation();
},
}); });
...@@ -121,10 +121,6 @@ Polymer({ ...@@ -121,10 +121,6 @@ Polymer({
/** @private */ /** @private */
onAndroidAppsSubpageTap_(event) { onAndroidAppsSubpageTap_(event) {
if (event.target && event.target.tagName == 'A') {
// Filter out events coming from 'Learn more' link
return;
}
if (this.androidAppsInfo.playStoreEnabled) { if (this.androidAppsInfo.playStoreEnabled) {
settings.Router.getInstance().navigateTo( settings.Router.getInstance().navigateTo(
settings.routes.ANDROID_APPS_DETAILS); settings.routes.ANDROID_APPS_DETAILS);
......
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