Fixes issue 20872: Context menu works even if focus in another tab
authorAugusto Mauch <augusto.mauch@openbravo.com>
Fri, 07 Sep 2012 11:11:35 +0200
changeset 17875 df2620bbba16
parent 17874 5d92fcb2d39f
child 17876 eee95a10d2d7
Fixes issue 20872: Context menu works even if focus in another tab

The root cause of this issue was that if the user opened the context menu in a view when the focus was in another view, the tab were the action was going to take place was not set as active.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Sep 07 10:41:55 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Sep 07 11:11:35 2012 +0200
@@ -305,6 +305,19 @@
       this.contextMenu = this.getMenuConstructor().create({
         items: menuItems
       });
+      this.contextMenu.show = function () {
+        var me = this;
+        if (!grid.view.isActiveView()) {
+          // The view where the context menu is being opened must be active
+          // See issue https://issues.openbravo.com/view.php?id=20872
+          grid.view.setAsActiveView(true);
+          setTimeout(function () {
+            me.Super('show', arguments);
+          }, 10);
+        } else {
+          me.Super('show', arguments);
+        }
+      };
     }
 
     var ret = this.Super('initWidget', arguments);