Skip to content

Commit fa3d4bd

Browse files
committed
[frontend] improve suggestions ui
1 parent 4cc8fe9 commit fa3d4bd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

frontend/src/components/Omnibox.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,29 @@ export const UrlInput: Component<
6363
}, 10);
6464
});
6565

66+
let lastgooglesuggestions: OmniboxResult[] = [];
6667
const fetchSuggestions = async () => {
6768
let search = this.input.value;
6869

69-
this.overflowItems = [];
70+
this.overflowItems = lastgooglesuggestions;
71+
72+
let googlesuggestions: OmniboxResult[] = [];
7073

7174
for (const entry of browser.globalhistory) {
7275
if (!entry.url.href.includes(search) && !entry.title?.includes(search))
7376
continue;
74-
if (this.overflowItems.some((i) => i.url.href === entry.url.href))
77+
if (googlesuggestions.some((i) => i.url.href === entry.url.href))
7578
continue;
7679

77-
this.overflowItems.push({
80+
googlesuggestions.push({
7881
kind: "history",
7982
title: entry.title,
8083
url: entry.url,
8184
favicon: entry.favicon,
8285
});
8386
}
84-
this.overflowItems = this.overflowItems.slice(0, 5);
87+
lastgooglesuggestions = googlesuggestions.slice(0, 5);
88+
this.overflowItems = googlesuggestions.slice(0, 5);
8589

8690
if (URL.canParse(search)) {
8791
this.overflowItems = [
@@ -194,15 +198,15 @@ export const UrlInput: Component<
194198
<span class="description">
195199
{item.title.startsWith(this.input.value) ? (
196200
<>
197-
<span>
198-
{item.title.substring(0, this.input.value.length)}
199-
</span>
200201
<span style="font-weight: normal; opacity: 0.7;">
201-
{item.title.substring(this.input.value.length)}
202+
{item.title.substring(0, this.input.value.length)}
202203
</span>
204+
<span>{item.title.substring(this.input.value.length)}</span>
203205
</>
204206
) : (
205-
<span>item.title</span>
207+
<span style="font-weight: normal; opacity: 0.7;">
208+
{item.title}
209+
</span>
206210
)}
207211
<span>{" - "}</span>
208212
</span>

0 commit comments

Comments
 (0)