Skip to content
Merged
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
35 changes: 35 additions & 0 deletions web-app/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,40 @@ textarea:focus-visible,
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.clear-search-btn {
position: absolute;
top: 50%;
right: 0.85rem;
transform: translateY(-50%);
width: 1.4rem;
height: 1.4rem;
border: none;
border-radius: 50%;
background: transparent;
color: var(--text-muted);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
transition: background-color 0.2s ease, color 0.2s ease;
z-index: 5;
}

.clear-search-btn:hover {
background: rgba(255, 255, 255, 0.08);
color: var(--text-color);
}

.clear-search-btn:focus-visible {
outline: 2px solid var(--accent-color);
outline-offset: 2px;
}

.search-box input {
padding-right: 3rem;
}

/* Search dropdown items — keyboard highlight */
.dropdown-item:focus-visible,
.dropdown-item.selected {
Expand Down Expand Up @@ -3946,6 +3980,7 @@ button:focus-visible,


.search-box {
position: relative;
max-width: none;
width: 100%;
}
Expand Down
8 changes: 8 additions & 0 deletions web-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
<i class="fas fa-search" aria-hidden="true"></i>
<input aria-label="Search projects" id="searchInput" placeholder="Search projects or tags..." type="text"
role="combobox" aria-autocomplete="list" aria-controls="resultsList" aria-expanded="false" />
<button
id="clearSearchBtn"
class="clear-search-btn"
type="button"
aria-label="Clear search"
hidden>
<i class="fas fa-times"></i>
</button>
<div class="search-dropdown" id="searchDropdown" aria-live="polite">
<div class="dropdown-content" id="searchDropdownContent">
<div class="search-loader" id="searchLoader" style="display: none">
Expand Down
41 changes: 36 additions & 5 deletions web-app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ document.addEventListener("DOMContentLoaded", function () {
var html = document.documentElement;
var backToTopButton = document.getElementById("backToTop");
var searchInput = document.querySelector(".sidebar-dock #searchInput");
const clearSearchBtn = document.getElementById("clearSearchBtn");
var navSearchInput = document.getElementById("navSearchInput");
var searchDropdown = document.getElementById("searchDropdown");
var searchLoader = document.getElementById("searchLoader");
Expand Down Expand Up @@ -1264,6 +1265,10 @@ if (searchInputs.length) {
var rawValue = e.target.value;
var query = rawValue.trim();
currentSearchQuery = query;

if (clearSearchBtn) {
clearSearchBtn.hidden = query === "";
}

// Show loader
if (searchLoader) {
Expand Down Expand Up @@ -1301,11 +1306,16 @@ if (searchInputs.length) {
// Keyboard navigation
input.addEventListener("keydown", function (e) {
if (e.key === "Escape") {
input.value = "";
currentSearchQuery = "";
performSearch(false);
closeDropdown();
input.blur();
input.value = "";
currentSearchQuery = "";

if (clearSearchBtn) {
clearSearchBtn.hidden = true;
}

performSearch(false);
closeDropdown();
input.blur();
}

if (e.key === "Enter") {
Expand Down Expand Up @@ -1345,6 +1355,27 @@ if (searchInputs.length) {
}
});
});

if (clearSearchBtn) {
clearSearchBtn.addEventListener("click", function () {

searchInputs.forEach(function (input) {
input.value = "";
});

currentSearchQuery = "";

performSearch(false);

closeDropdown();

clearSearchBtn.hidden = true;

if (searchInput) {
searchInput.focus();
}
});
}
}

// Close dropdown when clicking outside
Expand Down
Loading