fixed bug 25910: quick launch popup is not closed when item is selected
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 18 Mar 2014 11:11:05 +0100
changeset 22721 56436da527ee
parent 22720 c84042acbfab
child 22722 2c8c88e823d2
fixed bug 25910: quick launch popup is not closed when item is selected

Focus needs to be reset in order to make keyboard shortcuts work
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quickrun-widget.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quickrun-widget.js	Tue Mar 18 10:59:33 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quickrun-widget.js	Tue Mar 18 11:11:05 2014 +0100
@@ -187,6 +187,10 @@
     // }
     // }
     var left = this.getLeftPosition();
+
+    // keep current focus element to reset it after closing the widget
+    this.focusOnHide = isc.EH.getFocusCanvas();
+
     if (isc.Page.isRTL()) {
       left = left - this.layout.getVisibleWidth() + this.getVisibleWidth() + 1;
     }
@@ -237,6 +241,7 @@
   // ** {{{ doHide }}} **
   // Hide the expanded layout.
   doHide: function () {
+    var me = this;
     this.hideClickMask();
     this.layout.hide();
 
@@ -253,6 +258,16 @@
       isc.OBQuickRun.currentQuickRun = null;
     }
 
+    if (isc.isA.Canvas(this.focusOnHide)) {
+      // setting the focus back to a SC component so keyboard shortcuts continue
+      // working (they do not if focus is in browser). This is needed to be done
+      // with some delay in order to prevent enter key on drop down to be triggered
+      // on this new element (see issue #25910)
+      setTimeout(function () {
+        me.focusOnHide.focus();
+      }, 100);
+    }
+
     if (typeof OB.MainView.TabSet.getSelectedTab().pane.tabSelected === 'function') {
       OB.MainView.TabSet.getSelectedTab().pane.tabSelected();
     }