enhance: show close button when search box opened

This commit is contained in:
Tienson Qin
2025-12-30 17:03:24 +08:00
parent c97453d1dd
commit 45d592ecd5
2 changed files with 6 additions and 0 deletions

View File

@@ -175,6 +175,7 @@ a:hover {
.publish-search-toggle .ti {
font-size: 16px;
transition: transform 0.2s ease, opacity 0.2s ease;
}
.publish-search-input {

View File

@@ -413,6 +413,7 @@ const initSearch = () => {
const graphUuid = container.dataset.graphUuid;
const input = container.querySelector(".publish-search-input");
const toggleBtn = container.querySelector(".publish-search-toggle");
const toggleIcon = container.querySelector(".publish-search-toggle .ti");
const resultsEl = container.querySelector(".publish-search-results");
if (!input || !resultsEl || !toggleBtn) return;
@@ -560,6 +561,10 @@ const initSearch = () => {
const setExpanded = (expanded) => {
container.classList.toggle("is-expanded", expanded);
toggleBtn.setAttribute("aria-expanded", String(expanded));
if (toggleIcon) {
toggleIcon.classList.toggle("ti-search", !expanded);
toggleIcon.classList.toggle("ti-x", expanded);
}
if (expanded) {
input.focus();
} else {