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
15 changes: 15 additions & 0 deletions src/components/NetworkSwitcher.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof useSorokit>);

render(<NetworkSwitcher />);

expect(
screen.getByText(/Press Alt\+N to switch networks/i),
).toBeInTheDocument();
});
});

describe("client/network mismatch warning", () => {
Expand Down
11 changes: 10 additions & 1 deletion src/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down