From a33c42869a1a4054eb819af3f9389566cbd652b2 Mon Sep 17 00:00:00 2001 From: dreamerworks Date: Fri, 12 Jul 2024 16:27:10 +0100 Subject: [PATCH] improvement - allow partial head and footer for suggestions previously the header and footer for suggestions had to be full html elements. Example: head=
The Head
and footer=
The footer
. If we wanted to have: header= and have the suggestions to be
  • 's, the typeahead wouldn't work. This change makes it so that it works in both scenarios. --- src/typeahead/dataset.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/typeahead/dataset.js b/src/typeahead/dataset.js index fa154d9781..6ba28f35a1 100644 --- a/src/typeahead/dataset.js +++ b/src/typeahead/dataset.js @@ -141,9 +141,9 @@ var Dataset = (function() { $fragment = this._getSuggestionsFragment(query, suggestions); this.$lastSuggestion = $fragment.children().last(); - this.$el.html($fragment) - .prepend(this._getHeader(query, suggestions)) - .append(this._getFooter(query, suggestions)); + let newHtml = $([this._getHeader(query, suggestions),'
    ',this._getFooter(query, suggestions)].join('')); + newHtml.find('#__corejs-typeahead-suggestions-placeholder__').replaceWith($fragment); + this.$el.html(newHtml); }, _appendSuggestions: function appendSuggestions(query, suggestions) {