FIX: Hitting ESC while autocomplete is open shouldn't close the composer.
This commit is contained in:
parent
5cb1cc6fcb
commit
2e26fca36b
|
@ -115,17 +115,14 @@ $.fn.autocomplete = function(options) {
|
|||
};
|
||||
|
||||
var renderAutocomplete = function() {
|
||||
var borderTop, mePos, pos, ul;
|
||||
if (div) {
|
||||
div.hide().remove();
|
||||
}
|
||||
if (autocompleteOptions.length === 0) {
|
||||
return;
|
||||
}
|
||||
div = $(options.template({
|
||||
options: autocompleteOptions
|
||||
}));
|
||||
ul = div.find('ul');
|
||||
if (autocompleteOptions.length === 0) return;
|
||||
|
||||
div = $(options.template({ options: autocompleteOptions }));
|
||||
|
||||
var ul = div.find('ul');
|
||||
selectedOption = 0;
|
||||
markSelected();
|
||||
ul.find('li').click(function() {
|
||||
|
@ -133,7 +130,7 @@ $.fn.autocomplete = function(options) {
|
|||
completeTerm(autocompleteOptions[selectedOption]);
|
||||
return false;
|
||||
});
|
||||
pos = null;
|
||||
var pos = null;
|
||||
if (isInput) {
|
||||
pos = {
|
||||
left: 0,
|
||||
|
@ -149,9 +146,9 @@ $.fn.autocomplete = function(options) {
|
|||
left: "-1000px"
|
||||
});
|
||||
me.parent().append(div);
|
||||
mePos = me.position();
|
||||
borderTop = parseInt(me.css('border-top-width'), 10) || 0;
|
||||
return div.css({
|
||||
var mePos = me.position();
|
||||
var borderTop = parseInt(me.css('border-top-width'), 10) || 0;
|
||||
div.css({
|
||||
position: 'absolute',
|
||||
top: (mePos.top + pos.top - div.height() + borderTop) + 'px',
|
||||
left: (mePos.left + pos.left + 27) + 'px'
|
||||
|
@ -163,9 +160,9 @@ $.fn.autocomplete = function(options) {
|
|||
|
||||
autocompleteOptions = r;
|
||||
if (!r || r.length === 0) {
|
||||
return closeAutocomplete();
|
||||
closeAutocomplete();
|
||||
} else {
|
||||
return renderAutocomplete();
|
||||
renderAutocomplete();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -116,9 +116,13 @@ Discourse.ComposerView = Discourse.View.extend({
|
|||
// Search for similar topics if the user pauses typing
|
||||
controller.findSimilarTopics();
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
keyDown: function(e) {
|
||||
// If the user hit ESC
|
||||
if (e.which === 27) controller.hitEsc();
|
||||
if (e.which === 27) {
|
||||
this.get('controller').hitEsc();
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement: function() {
|
||||
|
|
Loading…
Reference in New Issue