From 3f5be23854a3ab7cfde29f1942856d43f538436a Mon Sep 17 00:00:00 2001 From: evykassirer Date: Mon, 18 Mar 2024 12:34:17 -0700 Subject: [PATCH] typeahead: Clean up render function. `final_items` is a list of `ItemType` so it doesn't make sense to wrap it in `$()`. Intead of creating a "jquery list of objects", we generate a list of JQuery objects. I also removed the unused `_index` in the `map` call. --- web/src/bootstrap_typeahead.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/bootstrap_typeahead.js b/web/src/bootstrap_typeahead.js index 46f4511fd4..252d55109d 100644 --- a/web/src/bootstrap_typeahead.js +++ b/web/src/bootstrap_typeahead.js @@ -350,7 +350,7 @@ Typeahead.prototype = { }, render(final_items, matching_items) { - const $items = $(final_items).map((_index, item) => { + const $items = final_items.map((item) => { const $i = $(ITEM_HTML).data("typeahead-value", item); const item_html = this.highlighter_html(item); const $item_html = $i.find("a").html(item_html); @@ -360,10 +360,10 @@ Typeahead.prototype = { if (option_label_html) { $item_html.append(option_label_html).addClass("typeahead-option-label"); } - return $i[0]; + return $i; }); - $items.first().addClass("active"); + $items[0].addClass("active"); this.$menu.empty().append($items); return this; },