diff --git a/src/components/NetworkSwitcher.test.tsx b/src/components/NetworkSwitcher.test.tsx index 0030952..20cb899 100644 --- a/src/components/NetworkSwitcher.test.tsx +++ b/src/components/NetworkSwitcher.test.tsx @@ -257,6 +257,21 @@ describe("NetworkSwitcher", () => { fireEvent.keyDown(document, { key: "n", code: "KeyN", altKey: true }); expect(screen.queryByText("Select Network")).not.toBeInTheDocument(); }); + + it("advertises the Alt+N shortcut in the trigger's tooltip text", () => { + vi.mocked(useSorokit).mockReturnValue({ + network: { name: "mainnet" }, + initialNetwork: { name: "mainnet" }, + switchNetwork: switchNetwork, + customNetworks: [], + } as unknown as ReturnType); + + render(); + + expect( + screen.getByText(/Press Alt\+N to switch networks/i), + ).toBeInTheDocument(); + }); }); describe("client/network mismatch warning", () => { diff --git a/src/components/NetworkSwitcher.tsx b/src/components/NetworkSwitcher.tsx index b843ab6..4613a3a 100644 --- a/src/components/NetworkSwitcher.tsx +++ b/src/components/NetworkSwitcher.tsx @@ -64,7 +64,16 @@ export const STANDARD_NETWORKS: NetworkPreset[] = [ }, ]; -/** Keyboard shortcut that toggles the network picker from anywhere. */ +/** + * Keyboard shortcut that toggles the network picker from anywhere in the + * application. The shortcut is wired to a `keydown` listener in + * `NetworkSwitcher` and is also advertised via the trigger button's + * `aria-keyshortcuts` attribute for assistive technologies. + * + * The currently selected network is persisted to + * `localStorage["sorokit_network"]` by `SorokitProvider.switchNetwork` and + * restored on next mount, so the user\u2019s choice survives a page reload. + */ export const NETWORK_SWITCHER_SHORTCUT = "Alt+N"; export function NetworkSwitcher() {