Bug 752988 - Focus lost when closing notification bars. r=enn
authorDão Gottwald <dao@mozilla.com>
Tue, 31 Jul 2012 16:24:37 +0200
changeset 100990 765da436c5b5e801085aaabb50d9c4ce3cab6b85
parent 100989 594e26e4d1030e2cefc94d98f5f05136b6acefbe
child 100991 1471876c787af7207169b569638bac8384c3ef48
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersenn
bugs752988
milestone17.0a1
Bug 752988 - Focus lost when closing notification bars. r=enn
toolkit/content/widgets/notification.xml
--- a/toolkit/content/widgets/notification.xml
+++ b/toolkit/content/widgets/notification.xml
@@ -163,16 +163,22 @@
 
       <method name="_removeNotificationElement">
         <parameter name="aChild"/>
         <body>
           <![CDATA[
             if (aChild.eventCallback)
               aChild.eventCallback("removed");
             this.removeChild(aChild);
+
+            // make sure focus doesn't get lost (workaround for bug 570835)
+            let fm = Components.classes["@mozilla.org/focus-manager;1"]
+                               .getService(Components.interfaces.nsIFocusManager);
+            if (!fm.getFocusedElementForWindow(window, false, {}))
+              fm.moveFocus(window, this, fm.MOVEFOCUS_FORWARD, 0);
           ]]>
         </body>
       </method>
 
       <method name="removeCurrentNotification">
         <parameter name="aSkipAnimation"/>
         <body>
           <![CDATA[