Bug 540506 - when focus is in the search box of the addons manager and you close the browser tools, keyboard stays up [r=mfinkle r=vingtetun]
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 14 Jun 2010 09:14:16 -0400
changeset 66283 f67966867bccdab6e02fda73cfcb27a6a3ab03d1
parent 66282 177f2450087e8d2c1a5968ea8f64e5cd3f23a9c8
child 66284 4d0e90b743161f0a47a3425d33ce9de3fa6ddefb
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, vingtetun
bugs540506
Bug 540506 - when focus is in the search box of the addons manager and you close the browser tools, keyboard stays up [r=mfinkle r=vingtetun]
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -336,16 +336,18 @@ var BrowserUI = {
     return targetNode ? true : false;
   },
 
   switchPane : function switchPane(id) {
     let button = document.getElementsByAttribute("linkedpanel", id)[0];
     if (button)
       button.checked = true;
 
+    this.blurFocusedElement();
+
     let pane = document.getElementById(id);
     document.getElementById("panel-items").selectedPanel = pane;
   },
 
   get toolbarH() {
     if (!this._toolbarH) {
       let toolbar = document.getElementById("toolbar-main");
       this._toolbarH = toolbar.boxObject.height;
@@ -633,22 +635,29 @@ var BrowserUI = {
 
     if (aPage != undefined)
       this.switchPane(aPage);
   },
 
   hidePanel: function hidePanel() {
     Elements.panelUI.hidden = true;
     Elements.contentShowing.removeAttribute("disabled");
+    this.blurFocusedElement();
   },
 
   isPanelVisible: function isPanelVisible() {
     return (!Elements.panelUI.hidden && Elements.panelUI.left == 0);
   },
 
+  blurFocusedElement: function blurFocusedElement() {
+    let focusedElement = document.commandDispatcher.focusedElement;
+    if (focusedElement)
+      focusedElement.blur();
+  },
+
   switchTask: function switchTask() {
     try {
       let phone = Cc["@mozilla.org/phone/support;1"].createInstance(Ci.nsIPhoneSupport);
       phone.switchTask();
     } catch(e) { }
   },
 
 #ifdef WINCE