Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: no search entries found page #5462

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions assets/js/registrySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ function executeSearch(searchQuery) {
let results = miniSearch.search(searchQuery);
document.getElementById('search-loading').style.display = 'none';

if (results.length > 0) {
populateResults(results);
} else {
document.querySelector('#search-results').innerHTML +=
'<p>No matches found</p>';
}
if (results.length === 0) {
document.getElementById('no-search-result').style.display = 'block';
}

populateResults(results);

Comment on lines +166 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code logic isn't correct. It breaks the responsiviness to form dropdown selection once a "no results" page has been viewed.

}, 0);
};

Expand Down
14 changes: 14 additions & 0 deletions layouts/shortcodes/ecosystem/registry/search-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
<span role="status">Loading results…</span>
</div>

<!-- When search hs no result -->
<div style="display: none; padding:20px; text-align: center;" id="no-search-result">
<div style="margin-left: auto; margin-right: auto; width: fit-content;">
{{ with resources.Get "icons/homepage-hero-as-background_hu89650641306215219.jpg" }}
<img style="border: none; margin-left: 40px;" src="{{ .RelPermalink }}" width="400" alt="no result found">
{{ end }}
</div>
<p style="color: #4f62ad; font-size: 28px; margin-bottom: 0;">Oops no results found</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we shouldn't be hardcoding styles here.

<p>No results match the filter criteria. Remove filter or clear all filters to show results</p>
<button type="button" class="btn btn-outline-danger"
onclick="document.getElementById('input-s').value = ''; document.getElementById('input-language').value = 'all';document.getElementById('input-component').value = 'all';document.getElementById('searchForm').submit();">Reset filters</button>
</div>

<ul class="list-unstyled" id="search-results"></ul>
<ul class="list-unstyled" id="default-body">
{{ range $key, $value := $registry -}}
Expand Down