From ad017434dcbf28d60b6bcb13d2af528222839181 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Fri, 28 Feb 2020 01:54:16 +0530 Subject: [PATCH] closes reorder/remove dialog when a click is made outside or when escape key is presses --- .../dialogs/column-reordering-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js index 3343f8483..5de661475 100644 --- a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js @@ -67,10 +67,34 @@ ColumnReorderingDialog.prototype._createDialog = function() { connectWith: '.column-reordering-dialog-column-container' }) .disableSelection(); + + var justOpened = true; + var clickOutside = function(event) { + $target = $(event.target); + var dialog = $('.dialog-frame'); + var dist = $target.closest(dialog).length; + if(justOpened) { + justOpened = false; + return; + } + if(dist == 0 && $(dialog).is(':visible') && !justOpened) { + self._dismiss(); + } + } + $(document).click(clickOutside); + + var escapeKey = function(event) { + if (event.keyCode == 27) { + self._dismiss(); + } + } + $(window).keydown(escapeKey); }; ColumnReorderingDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; ColumnReorderingDialog.prototype._commit = function() {