Fixed various problems with the quicksearch

This commit is contained in:
Jan Böhmer 2024-02-29 23:00:21 +01:00
parent 04aeab7ea6
commit e0ef376cf0
3 changed files with 5 additions and 3 deletions

View file

@ -42,6 +42,7 @@ export default class extends Controller {
_autocomplete; _autocomplete;
// Highlight the search query in the results
_highlight = (text, query) => { _highlight = (text, query) => {
if (!text) return text; if (!text) return text;
if (!query) return text; if (!query) return text;
@ -77,7 +78,7 @@ export default class extends Controller {
this._autocomplete = autocomplete({ this._autocomplete = autocomplete({
container: this.element, container: this.element,
//Place the panel in the navbar, if the element is in navbar mode //Place the panel in the navbar, if the element is in navbar mode
panelContainer: navbar_mode ? document.getElementById("navbar-frame") : document.body, panelContainer: navbar_mode ? document.getElementById("navbar-search-form") : document.body,
panelPlacement: this.element.dataset.panelPlacement, panelPlacement: this.element.dataset.panelPlacement,
plugins: [recentSearchesPlugin], plugins: [recentSearchesPlugin],
openOnFocus: true, openOnFocus: true,

View file

@ -89,12 +89,12 @@
{% if is_navbar %}id="navbar-quicksearch-container"{% endif %} {% if is_navbar %}id="navbar-quicksearch-container"{% endif %}
data-panel-placement="{% if is_navbar %}end{% else %}input-wrapper-width{% endif %}" data-panel-placement="{% if is_navbar %}end{% else %}input-wrapper-width{% endif %}"
data-mode-navbar="{% if is_navbar %}true{% else %}false{% endif %}" data-navbar-mode="{% if is_navbar %}true{% else %}false{% endif %}"
data-placeholder-image="{{ asset('img/part_placeholder.svg') }}" data-placeholder-image="{{ asset('img/part_placeholder.svg') }}"
data-autocomplete="{{ path('typeahead_parts', {'query': '__QUERY__'}) }}" data-autocomplete="{{ path('typeahead_parts', {'query': '__QUERY__'}) }}"
data-detail-url="{{ path('part_info', {'id': '__ID__'}) }}"> data-detail-url="{{ path('part_info', {'id': '__ID__'}) }}">
<input type="hidden" name="keyword" required {{ stimulus_target('elements/part_livesearch', 'input') }}> <input type="hidden" name="keyword" required {{ stimulus_target('elements/part_search', 'input') }}>
</div> </div>
{# And right in the standalone mode #} {# And right in the standalone mode #}

View file

@ -11,6 +11,7 @@
{% if is_granted('@parts.read') %} {% if is_granted('@parts.read') %}
{{ search.search_form("standalone") }} {{ search.search_form("standalone") }}
<div class="mb-2"></div>
{% endif %} {% endif %}