Browse Source

HUE-2381 [fb] Right click menu is not always hidden when clicking outside

Added event handler to determine if context click occurs outside of file list in order to close the context menu
Paul McCaughtry 11 năm trước cách đây
mục cha
commit
b6edd5ce00

+ 16 - 7
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1254,6 +1254,15 @@ from django.utils.translation import ugettext as _
       };
       };
     };
     };
 
 
+    // hide the context menu based on specific events
+    var hideContextMenu = function () {
+      var cm = $('.context-menu');
+
+      if (cm.is(':visible')) {
+        cm.css({ display: 'none' });
+      }
+    };
+
     var viewModel = new FileBrowserModel([], null, [], "/");
     var viewModel = new FileBrowserModel([], null, [], "/");
     ko.applyBindings(viewModel);
     ko.applyBindings(viewModel);
 
 
@@ -1274,17 +1283,17 @@ from django.utils.translation import ugettext as _
 
 
       // hide context menu
       // hide context menu
       $('body').on('click', function (e) {
       $('body').on('click', function (e) {
-        var cm = $('.context-menu');
-        if (cm.is(':visible')) {
-          cm.css({ display: 'none' });
+        hideContextMenu();
+      });
+
+      $('body').on('contextmenu', function (e) {
+        if ($.inArray(e.toElement, $('.datatables *')) === -1) {
+          hideContextMenu();
         }
         }
       });
       });
 
 
       $('body').on('contextmenu', '.context-menu', function (e) {
       $('body').on('contextmenu', '.context-menu', function (e) {
-        var cm = $('.context-menu');
-        if (cm.is(':visible')) {
-          cm.css({ display: 'none' });
-        }
+        hideContextMenu();
       });
       });
 
 
       // Drag and drop uploads from anywhere on filebrowser screen
       // Drag and drop uploads from anywhere on filebrowser screen