mirror of https://github.com/zulip/zulip.git
search pills: Backspace should remove a search pill with typeahead open.
Fixes part of #10026. Typeaheads stopped propogation of keydown and keyup events for any key except tab and enter. If stopAdvance was true even tab and enter were not allowed. advanceKeyCodes option was added to typeahead which allowed to specify key codes for which propogation of keydown and keyup events should not stop. advanceKeyCodes does not respect the stopAdvance option. As the backspace key code is added to advanceKeyCodes in search.js, the backspace key deletes pill on pressing backspace if input is empty or only consists of spaces.
This commit is contained in:
parent
4186ebe56a
commit
28589c5563
|
@ -117,6 +117,7 @@ exports.initialize = function () {
|
|||
return items;
|
||||
},
|
||||
stopAdvance: page_params.search_pills_enabled,
|
||||
advanceKeyCodes: [8],
|
||||
});
|
||||
|
||||
searchbox_form.on('compositionend', function () {
|
||||
|
|
|
@ -2046,7 +2046,8 @@
|
|||
break
|
||||
}
|
||||
|
||||
if (this.options.stopAdvance || (e.keyCode != 9 && e.keyCode != 13)) {
|
||||
if ((this.options.stopAdvance || (e.keyCode != 9 && e.keyCode != 13))
|
||||
&& $.inArray(e.keyCode, this.options.advanceKeyCodes)) {
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
|
@ -2082,7 +2083,8 @@
|
|||
this.lookup()
|
||||
}
|
||||
|
||||
if (this.options.stopAdvance || (e.keyCode != 9 && e.keyCode != 13)) {
|
||||
if ((this.options.stopAdvance || (e.keyCode != 9 && e.keyCode != 13))
|
||||
&& $.inArray(e.keyCode, this.options.advanceKeyCodes)) {
|
||||
e.stopPropagation()
|
||||
}
|
||||
|
||||
|
@ -2133,6 +2135,7 @@
|
|||
, minLength: 1
|
||||
, stopAdvance: false
|
||||
, dropup: false
|
||||
, advanceKeyCodes: []
|
||||
}
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead
|
||||
|
|
Loading…
Reference in New Issue