diff --git a/apps/content/src/browser/components/Browser.svelte b/apps/content/src/browser/components/Browser.svelte index 7333003..ca5ecd6 100644 --- a/apps/content/src/browser/components/Browser.svelte +++ b/apps/content/src/browser/components/Browser.svelte @@ -40,7 +40,8 @@ display: none; } - :global(browser) { + .browser-container :global(browser) { flex-grow: 1; + color-scheme: env(-moz-content-preferred-color-scheme); } diff --git a/apps/content/src/browser/components/keybindings/Keybindings.svelte b/apps/content/src/browser/components/keybindings/Keybindings.svelte index b5fbb52..c84f07a 100644 --- a/apps/content/src/browser/components/keybindings/Keybindings.svelte +++ b/apps/content/src/browser/components/keybindings/Keybindings.svelte @@ -35,6 +35,10 @@ pref="browser.keybinds.closeTab" on:command={() => runOnCurrentTab(closeTab)} /> + runOnCurrentTab((tab) => tab.reload())} + /> setCurrentTabIndex(getCurrentTabIndex() + 1)} diff --git a/apps/content/src/browser/components/omnibox/Omnibox.svelte b/apps/content/src/browser/components/omnibox/Omnibox.svelte index ce341c5..0d7897a 100644 --- a/apps/content/src/browser/components/omnibox/Omnibox.svelte +++ b/apps/content/src/browser/components/omnibox/Omnibox.svelte @@ -16,40 +16,49 @@ export let tab: Tab - let showFocus = false let inputContent: string = '' let inputElement: HTMLInputElement let suggestions: Suggestion[] = [] let selectedSuggestion = 0 + $: focusedOmnibox = tab.focusedOmnibox $: uri = tab.uri $: zoom = tab.zoom - async function generateSuggestions() { - const { suggestions: suggestionsMethod } = await suggestionsModule - suggestions = await suggestionsMethod(inputContent) + const setSuggestions = (query: string) => (s: Suggestion[]) => { + if (query != inputContent) return + suggestions = s selectedSuggestion = Math.max( Math.min(selectedSuggestion, suggestions.length - 1), 0, ) } - const unbindedSetInputContent = (value: string) => { - inputContent = value - if (tab.tabJustOpened && inputElement) { - inputElement.focus() - inputElement.select() - tab.tabJustOpened = false - return - } + async function generateSuggestions() { + const { suggestions: suggestionsMethod } = await suggestionsModule + const { fast, full } = suggestionsMethod(inputContent) + + fast.then(setSuggestions(inputContent)) + full.then(setSuggestions(inputContent)) + } + + function updateFocus(shouldBeFocused: boolean, url: string) { + inputContent = url + if (!inputElement) return - // Unfocus on spec change - if (inputElement && suggestions.length != 0) { + const isFocused = document.activeElement === inputElement + if (isFocused === shouldBeFocused) return + + if (shouldBeFocused) { + inputElement.focus() + setTimeout(() => inputElement.select(), 100) + } else { inputElement.blur() suggestions = [] } } - $: unbindedSetInputContent($uri.asciiSpec) + + $: updateFocus($focusedOmnibox, $uri.asciiSpec)
@@ -63,16 +72,22 @@ bind:this={inputElement} bind:value={inputContent} on:focusin={() => { - showFocus = true + focusedOmnibox.set(true) generateSuggestions() }} on:blur|capture={() => - setTimeout(() => (showFocus = false) && (suggestions = []), 100)} + setTimeout(() => { + focusedOmnibox.set(false) + suggestions = [] + }, 100)} on:keyup={async (e) => { - if (e.key === 'Enter') + if (e.key === 'Enter') { + focusedOmnibox.set(false) return tab.goToUri( resource.NetUtil.newURI(suggestions[selectedSuggestion].url), ) + } + if (e.key === 'ArrowDown') { e.preventDefault() selectedSuggestion = Math.min( @@ -104,7 +119,7 @@