Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1745)

Unified Diff: chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js

Issue 1799303002: [Media Router] Disable focus if not triggered by user. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
diff --git a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
index 8dd96b91c06e5468a704e68ce533d212554f3ad0..35f03eacabc9025837220165db18024f2ead196c 100644
--- a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
+++ b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
@@ -84,6 +84,10 @@ Polymer({
},
},
+ listeners: {
+ 'focus': 'onFocus_',
+ },
+
attached: function() {
// isRTL() only works after i18n_template.js runs to set <html dir>.
// Set the back button icon based on text direction.
@@ -132,18 +136,6 @@ Polymer({
},
/**
- * Handles a click on the arrow button by firing an arrow-click event.
- *
- * @private
- */
- onHeaderOrArrowClick_: function() {
- if (this.view == media_router.MediaRouterView.SINK_LIST ||
- this.view == media_router.MediaRouterView.CAST_MODE_LIST) {
- this.fire('header-or-arrow-click');
- }
- },
-
- /**
* Handles a click on the back button by firing a back-click event.
*
* @private
@@ -164,6 +156,32 @@ Polymer({
},
/**
+ * Called when a focus event is triggered.
+ *
+ * @param {!Event} event The event object.
+ * @private
+ */
+ onFocus_: function(event) {
+ // If the focus event was not triggered by the user, remove focus from
+ // the element. This prevents unexpected focusing such as when the dialog
+ // is initially loaded.
+ if (!event.sourceCapabilities)
+ event.path[0].blur();
imcheng 2016/03/14 23:34:50 would that cause blur event to fire? https://code.
apacible 2016/03/14 23:53:37 No, this only blurs the specific element.
+ },
+
+ /**
+ * Handles a click on the arrow button by firing an arrow-click event.
+ *
+ * @private
+ */
+ onHeaderOrArrowClick_: function() {
+ if (this.view == media_router.MediaRouterView.SINK_LIST ||
+ this.view == media_router.MediaRouterView.CAST_MODE_LIST) {
+ this.fire('header-or-arrow-click');
+ }
+ },
+
+ /**
* Updates header height to accomodate email text. This is called on changes
* to |showEmail| and will return early if the value has not changed.
*

Powered by Google App Engine
This is Rietveld 408576698