Skip to content

Active search - display all artists when search box is empty #2

@tataraba

Description

@tataraba

For 04_htmx branch:

When selecting the "search" element (<input>), the html response that gets rendered in the "#search-results" div is empty (nothing found).

image

Instead, the element should populate with all artists by default. Once the search is started (on keypress), it filters down appropriately.

Right now, the search.html template has this block:

{% block content %}
<section id="body" class="flex flex-col bg-slate-50 justify-center items-center max-w-screen-lg m-auto">
    <div class="flex flex-col justify-center items-center py-10 min-w-full">
        <h2 class="text-2xl leading-relaxed text-slate-800 uppercase">Search Results</h2>
        <div id="search-results" class="flex flex-row flex-wrap justify-center content-center text-center w-full">
            {% if search|list %}
                {% for result in results %}
                    <p>{{result["name"]}}</p>
                {% endfor %}
            {% else %}
                <p>No results found.</p>
            {% endif %}
        </div>
    </div>
</section>
{% endblock %}

Maybe adding a default for all results in the {% else %} statement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions