Enforce same keyboard behaviour as tryton

- down key put the focus on the menu
- return key does not open the menu
- escape key does not close modal

issue7296
review37181002
This commit is contained in:
Cédric Krier committed 2018-04-04 23:03:23 +02:00
1 parent 11486416c4
commit 7defe1ddff
2 files changed
+21 -3

No files matched your search

+13 -3
View File
@@ -3063,14 +3063,24 @@
this.input.keydown(function(evt) {
if (evt.which == Sao.common.ESC_KEYCODE) {
if (this.dropdown.hasClass('open')) {
evt.preventDefault();
evt.stopPropagation();
this.menu.dropdown('toggle');
}
} else if (evt.which == Sao.common.RETURN_KEYCODE) {
if (!this.dropdown.hasClass('open')) {
this.menu.dropdown('toggle');
} else if (evt.which == Sao.common.DOWN_KEYCODE) {
if (this.dropdown.hasClass('open')) {
evt.preventDefault();
this.menu.find('li > a').first().focus();
}
}
}.bind(this));
this.menu.keydown(function(evt) {
if (evt.which == Sao.common.ESC_KEYCODE) {
evt.preventDefault();
evt.stopPropagation();
this.menu.dropdown('toggle');
}
}.bind(this));
// We must set the overflow of the treeview containing the input to
// visible to prevent vertical scrollbar inherited from the auto
// overflow-x
+8
View File
@@ -607,6 +607,14 @@ var Sao = {};
this.update.bind(this),
this.match_selected.bind(this),
this.format.bind(this));
completion.input.keydown(function(evt) {
if (evt.which == Sao.common.RETURN_KEYCODE) {
if (!completion.dropdown.hasClass('open')) {
evt.preventDefault();
completion.menu.dropdown('toggle');
}
}
});
},
format: function(content) {
var el = jQuery('<div/>');