Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions frame/src/features/search/components/LauncherPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<script lang="ts">
import { onMount, untrack } from "svelte";
import { onMount, tick, untrack } from "svelte";
import { Globe02Icon, Search01Icon } from "@hugeicons/core-free-icons";
import * as m from "$shared/i18n/messages";
import type { PanelState, ToolKind } from "$shared/ipc/bindings";
Expand Down Expand Up @@ -193,8 +193,18 @@
// Editing a page's address opens on that address, selected, so typing
// replaces it and Return goes back to it.
surface.begin(next);
input?.focus();
input?.select();
// The seeded value must reach the DOM before selection is applied.
void tick().then(() => {
if (
bound !== next.session_id ||
!context?.visible ||
context.session_id !== next.session_id ||
!input?.isConnected
)
return;
input.focus();
input.select();
});
} else if (bound !== null) {
bound = null;
menu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ test("editing an address asks for that address and never for an empty field firs
await new Promise((done) => setTimeout(done, 100));
expect(native.search.mock.calls.map(([query]) => query)).toEqual(["https://example.com/"]);
await expect.element(screen.getByRole("combobox")).toHaveValue("https://example.com/");
const input = screen.getByRole("combobox").element() as HTMLInputElement;
expect(document.activeElement).toBe(input);
expect([input.selectionStart, input.selectionEnd]).toEqual([0, input.value.length]);
await userEvent.keyboard("https://github.com/");
await expect.element(screen.getByRole("combobox")).toHaveValue("https://github.com/");
});

test("sleeping past the resume deadline clears a query even when its timer never fired", async () => {
Expand Down