mirror of https://github.com/zulip/zulip.git
bootstrap_typeahead: Fix bug on select with no active item.
This bug was introduced in d9f25d01a1
It's possible that `find(".active")` returns `undefined` here.
This commit is contained in:
parent
b6597896b0
commit
6ff793590f
|
@ -322,7 +322,8 @@ export class Typeahead<ItemType extends string | object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
select(e?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent): this {
|
select(e?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent): this {
|
||||||
const val = this.values.get(the(this.$menu.find(".active")));
|
const active_option = this.$menu.find(".active")[0];
|
||||||
|
const val = active_option ? this.values.get(active_option) : undefined;
|
||||||
// It's possible that we got here from pressing enter with nothing highlighted.
|
// It's possible that we got here from pressing enter with nothing highlighted.
|
||||||
if (!this.requireHighlight && val === undefined) {
|
if (!this.requireHighlight && val === undefined) {
|
||||||
return this.hide();
|
return this.hide();
|
||||||
|
|
Loading…
Reference in New Issue