patx/gitman

fix repo search javascript

Commit 0c2e9fe · patx · 2026-05-05T17:10:10-04:00

Changeset
0c2e9fe3bf3ac32b714c3f53d80c59ef864c4c21
Parents
d3571c2d177d1c5706e14a610b5e7f11286c8d89

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/static/styles.css b/static/styles.css
index 93c6d85..c57a554 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -132,6 +132,9 @@ button, .button {
   box-shadow: 0 .4rem 1.2rem var(--shadow);
 }
 .repo-search-result {
+  display: block;
+}
+.repo-search-link {
   display: flex;
   justify-content: space-between;
   gap: .75rem;
@@ -141,21 +144,21 @@ button, .button {
   color: var(--text);
   text-decoration: none;
 }
-.repo-search-result:hover, .repo-search-result:focus {
+.repo-search-link:hover, .repo-search-link:focus {
   background: var(--ref-hover);
   text-decoration: none;
 }
-.repo-search-result strong {
+.repo-search-link strong {
   min-width: 0;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
 }
-.repo-search-result small {
+.repo-search-link small {
   flex: 0 0 auto;
   white-space: nowrap;
 }
-.repo-search-result small, .repo-search-empty { color: var(--muted); }
+.repo-search-link small, .repo-search-empty { color: var(--muted); }
 .repo-search-empty { margin: 0; padding: .3rem .4rem; }
 .ref-picker { position: relative; display: inline-block; }
 .ref-picker-menu {
diff --git a/templates/base.tpl b/templates/base.tpl
index 6c5a7a6..788189d 100644
--- a/templates/base.tpl
+++ b/templates/base.tpl
@@ -227,24 +227,26 @@
         clearResults();
 
         results.forEach((result) => {
+          const item = document.createElement("div");
           const link = document.createElement("a");
           const title = document.createElement("strong");
           const meta = document.createElement("small");
 
-          link.className = "repo-search-result";
+          item.className = "repo-search-result";
+          item.dataset.repoSearchResult = "true";
+          link.className = "repo-search-link";
           link.href = result.url || "#";
           link.setAttribute("role", "option");
-          link.dataset.repoSearchResult = "true";
           title.textContent = result.full_name || `${result.owner_username}/${result.name}`;
-          link.append(title);
 
           meta.textContent = (result.star_count || 0) === 1 ? "1 star" : `${result.star_count || 0} stars`;
-          link.append(meta);
+          link.append(title, document.createTextNode(" "), meta);
+          item.append(link);
 
           if (empty) {
-            menu.insertBefore(link, empty);
+            menu.insertBefore(item, empty);
           } else {
-            menu.append(link);
+            menu.append(item);
           }
         });