Parcourir la source

HUE-5244 [assist] Close the context popover on esc

Johan Ahlen il y a 8 ans
Parent
commit
02762ee2be
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      desktop/core/src/desktop/templates/sql_context_popover.mako

+ 12 - 0
desktop/core/src/desktop/templates/sql_context_popover.mako

@@ -1261,6 +1261,18 @@ from metadata.conf import has_navigator
           });
           });
         }
         }
 
 
+        var closeOnEsc = function (e) {
+          if (e.keyCode === 27) {
+            hidePopover();
+          }
+        };
+
+        $(document).on('keyup', closeOnEsc);
+
+        self.disposalFunctions.push(function () {
+          $(document).off('keyup', closeOnEsc);
+        });
+
         window.setTimeout(function() {
         window.setTimeout(function() {
           $(document).on('click', hideOnClickOutside);
           $(document).on('click', hideOnClickOutside);
         }, 0);
         }, 0);