From ceb84e0aea4c13617268d32ded1cbf2282a6bf92 Mon Sep 17 00:00:00 2001 From: ashley Date: Sun, 17 Aug 2025 15:18:34 +0200 Subject: [PATCH] Update html/map.ejs --- html/map.ejs | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/html/map.ejs b/html/map.ejs index 5cae6d29..783203c3 100644 --- a/html/map.ejs +++ b/html/map.ejs @@ -792,25 +792,32 @@ if (bar) { closeSearch.style.cursor = "pointer"; closeSearch.style.zIndex = "999"; - // attach to search container - const searchDiv = document.querySelector(".search"); - searchDiv.style.position = "relative"; - searchDiv.appendChild(closeSearch); +// Add floating X on the suggestions (places) div +const sugg = document.querySelector(".suggest"); +if (sugg) { + const closeBtn = document.createElement("button"); + closeBtn.textContent = "✕"; + closeBtn.title = "Clear suggestions"; - closeSearch.addEventListener("click", () => { - - document.querySelector("#suggestions").style.display = "none"; + // Style: float top-right, no background + Object.assign(closeBtn.style, { + position: "absolute", + top: "6px", + right: "8px", + border: "none", + background: "none", + color: "#fff", + fontSize: "18px", + cursor: "pointer", + zIndex: "10" }); - // shortcut to re-open with `/` - document.addEventListener("keydown", e => { - if (e.key === "/") { - if (searchDiv.style.display === "none") { - searchDiv.style.display = "flex"; - document.querySelector("#q").focus(); - e.preventDefault(); - } - } + sugg.style.position = "relative"; // anchor button inside + sugg.appendChild(closeBtn); + + closeBtn.addEventListener("click", () => { + // just clear the list items, keep div visible + sugg.querySelectorAll("li").forEach(li => li.remove()); }); } })();