File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export const App: Component = function (cx) {
1414 tabs = { use ( browser . tabs ) . bind ( ) }
1515 activetab = { use ( browser . activetab ) . bind ( ) }
1616 addTab = { ( ) => {
17- browser . newTab ( ) ;
17+ browser . newTab ( new URL ( "puter://newtab" ) , true ) ;
1818 } }
1919 destroyTab = { ( tab : Tab ) => {
2020 browser . destroyTab ( tab ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { createDelegate } from "dreamland/core";
66import tlds from "tlds" ;
77import type { SerializedHistoryState } from "./History" ;
88import { HistoryState } from "./History" ;
9+ import { focusOmnibox } from "./components/Omnibox" ;
910
1011export const pushTab = createDelegate < Tab > ( ) ;
1112export const popTab = createDelegate < Tab > ( ) ;
@@ -90,11 +91,12 @@ export class Browser extends StatefulClass {
9091 console . log ( this . activetab , this . activetab . url ) ;
9192 }
9293
93- newTab ( url ?: URL ) {
94+ newTab ( url ?: URL , focusomnibox : boolean = false ) {
9495 let tab = new Tab ( url ) ;
9596 pushTab ( tab ) ;
9697 this . tabs = [ ...this . tabs , tab ] ;
9798 this . activetab = tab ;
99+ if ( focusomnibox ) focusOmnibox ( ) ;
98100 return tab ;
99101 }
100102
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import { IconButton } from "./IconButton";
1313import { createDelegate , type Delegate } from "dreamland/core" ;
1414import type { Tab } from "../Tab" ;
1515
16+ export const focusOmnibox = createDelegate < void > ( ) ;
17+
1618export function trimUrl ( v : URL ) {
1719 return (
1820 ( v . protocol === "puter:" ? v . protocol : "" ) + v . host + v . pathname + v . search
@@ -53,6 +55,14 @@ export const UrlInput: Component<
5355 this . focusindex = 0 ;
5456 this . overflowItems = [ ] ;
5557 this . value = "" ;
58+
59+ focusOmnibox . listen ( ( ) => {
60+ console . log ( "WH" ) ;
61+ setTimeout ( ( ) => {
62+ activate ( ) ;
63+ } , 10 ) ;
64+ } ) ;
65+
5666 const fetchSuggestions = async ( ) => {
5767 let search = this . input . value ;
5868
@@ -213,11 +223,12 @@ export const UrlInput: Component<
213223 browser . activetab . pushNavigate (
214224 this . overflowItems [ this . focusindex - 1 ] . url
215225 ) ;
216- this . active = false ;
217- this . input . blur ( ) ;
218226 } else {
219227 browser . searchNavigate ( this . value ) ;
220228 }
229+
230+ this . active = false ;
231+ this . input . blur ( ) ;
221232 }
222233 } }
223234 on :input = { ( e : InputEvent ) => {
@@ -367,7 +378,7 @@ export const Omnibox: Component<{
367378 {
368379 label : "New Tab" ,
369380 action : ( ) => {
370- browser . newTab ( ) ;
381+ browser . newTab ( new URL ( "puter://newtab" ) , true ) ;
371382 } ,
372383 } ,
373384 {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export const NewTabPage: Component<
2424 > </ input >
2525 < div class = "suggestions" >
2626 { browser . globalhistory . slice ( 0 , 5 ) . map ( ( entry ) => (
27- < div class = "suggestion" on :click = { ( ) => browser . newTab ( ) } >
27+ < div class = "suggestion" on :click = { ( ) => browser . newTab ( entry . url ) } >
2828 < div class = "circle" >
2929 < img src = { entry . favicon || "/vite.svg" } alt = "favicon" />
3030 </ div >
You can’t perform that action at this time.
0 commit comments