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

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

Issue 1800213002: [Media Router WebUI] Update ESC handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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
« no previous file with comments | « no previous file | chrome/browser/resources/media_router/media_router.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
index fb34a147649ade3049aef041706237a478713609..c84092d121413645d27f610fcf75b9681bab67d9 100644
--- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
+++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
@@ -500,7 +500,7 @@ Polymer({
ready: function() {
this.elementReadyTimeMs_ = performance.now();
- document.addEventListener('keydown', this.checkForEscapePress_.bind(this));
+ document.addEventListener('keydown', this.onKeydown_.bind(this));
this.setSearchFocusHandlers_();
this.showSinkList_();
},
@@ -581,24 +581,6 @@ Polymer({
},
/**
- * Catch an Escape button press when searching to cause it to only exit the
- * filter view and not exit the dialog.
- * @param {!Event} e Keydown event object for the event.
- */
- checkForEscapePress_: function(e) {
- if (e.keyCode == media_router.KEYCODE_ESC) {
- if (this.isUserSearching_) {
- this.showSinkList_();
- e.preventDefault();
- } else {
- this.fire('close-dialog', {
- pressEscToClose: true,
- });
- }
- }
- },
-
- /**
* Compares two search match objects for sorting. Earlier and longer matches
* are prioritized.
*
@@ -1332,6 +1314,29 @@ Polymer({
},
/**
+ * Called when a keydown event is fired.
+ * @param {!Event} e Keydown event object for the event.
+ */
+ onKeydown_: function(e) {
+ // The ESC key may be pressed with a combination of other keys. It is
+ // handled on the C++ side instead of the JS side on non-mac platforms,
+ // which uses toolkit-views. Handle the expected behavior on all platforms
+ // here.
+ if (e.keyCode == media_router.KEYCODE_ESC && !e.shiftKey &&
+ !e.ctrlKey && !e.altKey && !e.metaKey) {
+ // When searching, allow ESC as a mechanism to leave the filter view.
+ if (this.isUserSearching_) {
+ this.showSinkList_();
+ e.preventDefault();
+ } else {
+ this.fire('close-dialog', {
+ pressEscToClose: true,
+ });
+ }
+ }
+ },
+
+ /**
* Called when a mouseleave event is triggered.
*
* @private
« no previous file with comments | « no previous file | chrome/browser/resources/media_router/media_router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698