Skip to content

Commit 71d1d62

Browse files
committed
[frontend] fix tab state bug
1 parent 5d0aa9e commit 71d1d62

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

frontend/src/Tab.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export class Tab extends StatefulClass {
2020
history: History;
2121

2222
constructor(public url: URL = new URL("puter://newtab")) {
23-
super(createState(new Object(Tab.prototype)));
23+
super(createState(Object.create(Tab.prototype)));
24+
2425
this.id = id++;
2526

2627
this.title = null;

frontend/src/components/Omnibox.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Spacer.css = `
2222

2323
export const UrlInput: Component<
2424
{
25-
tabUrl: string;
25+
tabUrl: URL;
2626
navigate: (url: string) => void;
2727
},
2828
{
@@ -76,7 +76,7 @@ export const UrlInput: Component<
7676
browser.unfocusframes = false;
7777
e.stopPropagation();
7878
});
79-
this.value = this.tabUrl;
79+
this.value = this.tabUrl.href;
8080
this.input.focus();
8181
this.input.select();
8282
e.stopPropagation();
@@ -149,12 +149,12 @@ export const UrlInput: Component<
149149
.map((a) => !a)
150150
.andThen(
151151
<span class="inactiveurl">
152-
{use(this.tabUrl).map((v) =>
153-
v && URL.canParse(v)
154-
? new URL(v).hostname +
155-
new URL(v).pathname +
156-
new URL(v).search
157-
: ""
152+
{use(this.tabUrl).map(
153+
(v) =>
154+
(v.protocol === "puter:" ? v.protocol : "") +
155+
v.host +
156+
v.pathname +
157+
v.search
158158
)}
159159
</span>
160160
)}
@@ -231,7 +231,7 @@ UrlInput.css = `
231231
`;
232232

233233
export const Omnibox: Component<{
234-
tabUrl: string;
234+
tabUrl: URL;
235235
navigate: (url: string) => void;
236236
goBack: () => void;
237237
goForwards: () => void;

frontend/src/components/Shell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Component } from "dreamland/core";
2-
import type { Tab } from "./TabStrip";
32
import { browser } from "../main";
43
import { popTab, pushTab } from "../browser";
4+
import type { Tab } from "../Tab";
55

66
export const Shell: Component<{
77
tabs: Tab[];

0 commit comments

Comments
 (0)