File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ Spacer.css = `
2424export const UrlInput : Component <
2525 {
2626 value : string ;
27+ navigate : ( url : string ) => void ;
2728 } ,
2829 {
2930 active : boolean ;
@@ -121,6 +122,14 @@ export const UrlInput: Component<
121122 }
122123 if ( e . key === "Enter" ) {
123124 e . preventDefault ( ) ;
125+ if ( this . focusindex > 0 ) {
126+ this . value = this . overflowItems [ this . focusindex - 1 ] ;
127+ this . navigate ( this . value ) ;
128+ this . active = false ;
129+ this . input . blur ( ) ;
130+ } else {
131+ this . navigate ( this . value ) ;
132+ }
124133 }
125134 } }
126135 on :input = { ( e : InputEvent ) => {
@@ -220,14 +229,15 @@ IconButton.css = `
220229
221230export const Omnibox : Component < {
222231 value : string ;
232+ navigate : ( url : string ) => void ;
223233} > = function ( cx ) {
224234 return (
225235 < div >
226236 < IconButton icon = { iconBack } > </ IconButton >
227237 < IconButton icon = { iconForwards } > </ IconButton >
228238 < IconButton icon = { iconRefresh } > </ IconButton >
229239 < Spacer > </ Spacer >
230- < UrlInput value = { use ( this . value ) } > </ UrlInput >
240+ < UrlInput value = { use ( this . value ) } navigate = { this . navigate } > </ UrlInput >
231241 < Spacer > </ Spacer >
232242 < IconButton icon = { iconExtension } > </ IconButton >
233243 < IconButton
Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ export class Browser extends StatefulClass {
109109 return tab ;
110110 }
111111
112+ navigate ( url : string ) {
113+ if ( URL . canParse ( url ) ) {
114+ this . activetab . frame . go ( url ) ;
115+ } else {
116+ const search = `https://google.com/search?q=${ encodeURIComponent ( url ) } ` ;
117+ this . activetab . frame . go ( search ) ;
118+ }
119+ }
120+
112121 destroyTab ( tab : Tab ) {
113122 this . tabs = this . tabs . filter ( ( t ) => t !== tab ) ;
114123 console . log ( this . tabs ) ;
@@ -145,7 +154,10 @@ export class Browser extends StatefulClass {
145154 } }
146155 > </ IconButton >
147156 </ div >
148- < Omnibox value = { use ( this . activetab . url ) } />
157+ < Omnibox
158+ value = { use ( this . activetab . url ) }
159+ navigate = { ( url ) => this . navigate ( url ) }
160+ />
149161 { shell }
150162 </ div >
151163 ) ;
You can’t perform that action at this time.
0 commit comments