diff --git a/src/common.js b/src/common.js index ff5db2e1b4..e8f9d7a05b 100644 --- a/src/common.js +++ b/src/common.js @@ -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 diff --git a/src/sao.js b/src/sao.js index 8bb5dbc7db..8723b3835a 100644 --- a/src/sao.js +++ b/src/sao.js @@ -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('
');