Skip to content

Commit 700cb80

Browse files
committed
[frontend] add context menu to new tab page suggestions
1 parent 4bcf1f0 commit 700cb80

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

frontend/src/pages/NewTabPage.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { css, type Component } from "dreamland/core";
22
import type { Tab } from "../Tab";
33
import { browser } from "../Browser";
44
import { trimUrl } from "../components/UrlInput";
5+
import { createMenu } from "../components/Menu";
56

67
export const NewTabPage: Component<
78
{
@@ -23,7 +24,24 @@ export const NewTabPage: Component<
2324
></input>
2425
<div class="suggestions">
2526
{browser.globalhistory.slice(0, 5).map((entry) => (
26-
<div class="suggestion" on:click={() => browser.newTab(entry.url)}>
27+
<div
28+
class="suggestion"
29+
on:contextmenu={(e: MouseEvent) => {
30+
createMenu(e.clientX, e.clientY, [
31+
{
32+
label: "Open",
33+
action: () => browser.activetab.pushNavigate(entry.url),
34+
},
35+
{
36+
label: "Open in New Tab",
37+
action: () => browser.newTab(entry.url),
38+
},
39+
]);
40+
e.preventDefault();
41+
e.stopPropagation();
42+
}}
43+
on:click={() => browser.newTab(entry.url)}
44+
>
2745
<div class="suggestioninner">
2846
<div class="circle">
2947
<img src={entry.favicon || "/vite.svg"} alt="favicon" />

0 commit comments

Comments
 (0)