Skip to content

docs(NetworkSwitcher): document Alt+N shortcut + persistence behavior (#342) + assert tooltip advertises it - #388

Merged
k-deejah merged 1 commit into
Sorokit:mainfrom
oladev2026-tech:wave-issue-342-networkswitcher-fix
Jul 29, 2026
Merged

docs(NetworkSwitcher): document Alt+N shortcut + persistence behavior (#342) + assert tooltip advertises it#388
k-deejah merged 1 commit into
Sorokit:mainfrom
oladev2026-tech:wave-issue-342-networkswitcher-fix

Conversation

@oladev2026-tech

Copy link
Copy Markdown
Contributor

Summary

Issue #342’s three flagged gaps already ship in source:

  • NETWORK_SWITCHER_SHORTCUT = "Alt+N" toggles the picker through a keydown listener and is mirrored in the trigger button’s aria-keyshortcuts attribute.
  • The mismatch badge (data-testid="network-mismatch-badge") appears when network.name !== initialNetwork.name and an in-dropdown role="alert" explains the difference.
  • Persistence: SorokitProvider.switchNetwork writes localStorage["sorokit_network"], and SorokitProvider restores it on next mount via client.network.switchNetwork(savedNet) (covered by the network persistence describe block in SorokitProvider.test.tsx).

This refactor:

  1. Documents the exported NETWORK_SWITCHER_SHORTCUT constant so it advertises the keyboard shortcut implementation and the persistence expectation to anyone reading the type system.
  2. Adds a regression test in describe("Alt+N keyboard shortcut") that the trigger tooltip text contains the shortcut (/Press Alt\+N to switch networks/i).

No runtime changes. No existing tests modified.

Notes

  • The tooltip text is mounted under Tooltip.Portal which is mocked to wrap-as-fragment in the test environment, so the helper assertion queries a DOM node that is present at first paint.
  • The constant remains a plain string Alt+N; the JSDoc only documents intent, not the keymap.
  • Backwards-compatible: any consumer that imports NETWORK_SWITCHER_SHORTCUT keeps getting the same string value.

Closes #342

…Sorokit#342) + assert tooltip advertises it

Issue Sorokit#342 lists three gaps that are already implemented in source and verify what is already covered by the existing Sorokit#353+ test suite (Alt+N keyboard shortcut, mismatch badge, persistence):

- `NETWORK_SWITCHER_SHORTCUT = \"Alt+N\"` is already wired to a `keydown` listener and `aria-keyshortcuts` on the trigger button.
- The mismatch badge computes `network.name !== initialNetwork.name` and a warning `<div role=\"alert\">` inside the dropdown.
- Persistence is implemented in `SorokitProvider.switchNetwork` which writes `localStorage[\"sorokit_network\"]` and `SorokitProvider` restores it on mount via `client.network.switchNetwork(savedNet)`.

This commit does the following refinements on top:

1. The exported `NETWORK_SWITCHER_SHORTCUT` constant now carries a JSDoc explaining that it (a) toggles the picker via a global keydown listener, (b) is mirrored in `aria-keyshortcuts` for accessibility, and (c) the selected network persists across reloads through `SorokitProvider`. Previously the constant was a bare string with no documentation.

2. A new test in `describe(\"Alt+N keyboard shortcut\")` asserts that the trigger-tooltip text contains `/Press Alt\\+N to switch networks/i` so the shortcut stays advertised to assistive tech. The tooltip was rendering the message in source but no test guarded the wording.

No changes to runtime behavior; one new export-side docstring + one new test.

Closes Sorokit#342
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@oladev2026-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@k-deejah
k-deejah merged commit c2e1f66 into Sorokit:main Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(NetworkSwitcher): selected network not persisted across reloads, no Alt+N keyboard shortcut, no mismatch badge vs initialised network

2 participants