Suppress Enter key presses in Alertify dialogues when the come from Select2 controls to allow item selection with Enter. Fixes #4610

This commit is contained in:
Aditya Toshniwal 2019-10-30 10:42:06 +00:00 committed by Dave Page
parent fbc3e2d0e7
commit 4bec7df33b
2 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ Bug fixes
| `Issue #4482 <https://redmine.postgresql.org/issues/4482>`_ - Ensure compression level is passed to pg_dump when backing up in directory format.
| `Issue #4483 <https://redmine.postgresql.org/issues/4483>`_ - Ensure the number of jobs can be specified when backing up in directory format.
| `Issue #4564 <https://redmine.postgresql.org/issues/4564>`_ - Ensure Javascript errors during Query Tool execution are reported as such and not as Ajax errors.
| `Issue #4610 <https://redmine.postgresql.org/issues/4610>`_ - Suppress Enter key presses in Alertify dialogues when the come from Select2 controls to allow item selection with Enter.
| `Issue #4730 <https://redmine.postgresql.org/issues/4730>`_ - Ensure all messages are retained in the Query Tool from long running queries.
| `Issue #4845 <https://redmine.postgresql.org/issues/4845>`_ - Fixed potential error in the properties dialog for the Code tab.
| `Issue #4850 <https://redmine.postgresql.org/issues/4850>`_ - Fixed an issue where Datetimepicker control opens when clicking on the label.

View File

@ -463,5 +463,24 @@ define([
reverseButtons: true,
});
/* Suppress the enter key events occurring from select2 boxes
* so that the dialog does not close.
* Alertify listens to keyup events on the body element unfortunately
* instead of alertify dialog
*/
$('body').off('keyup').on('keyup', function(ev){
if(ev.which === 13) {
let suppressForClasses = ['select2-selection', 'select2-search__field'];
let $el = $(ev.target);
for(let i=0; i<suppressForClasses.length; i++){
if($el.hasClass(suppressForClasses[i])){
ev.preventDefault();
ev.stopImmediatePropagation();
ev.stopPropagation();
break;
}
}
}
});
return alertify;
});