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:
evykassirer 2024-08-21 13:08:37 -07:00 committed by Tim Abbott
parent b6597896b0
commit 6ff793590f
1 changed files with 2 additions and 1 deletions

View File

@ -322,7 +322,8 @@ export class Typeahead<ItemType extends string | object> {
}
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.
if (!this.requireHighlight && val === undefined) {
return this.hide();