Skip to content

Move Sidenav keyboard shortcut into Leptos - #47

Open
JamesbbBriz wants to merge 2 commits into
rust-ui:mainfrom
JamesbbBriz:codex/registry-v2-contract
Open

Move Sidenav keyboard shortcut into Leptos#47
JamesbbBriz wants to merge 2 commits into
rust-ui:mainfrom
JamesbbBriz:codex/registry-v2-contract

Conversation

@JamesbbBriz

@JamesbbBriz JamesbbBriz commented Jul 25, 2026

Copy link
Copy Markdown

Problem

The Sidenav keyboard shortcut was owned by a globally loaded JavaScript sidecar. That bypassed the Leptos component lifecycle, queried the DOM globally, and required the application shell to load component-specific JavaScript.

What changed

  • move Ctrl+B / Cmd+B handling into SidenavWrapper
  • update the existing RwSignal<bool> through SidenavContext
  • ignore input, textarea, and inherited contenteditable focus targets
  • reject Shift/Alt-modified shortcuts and respect an already-handled event
  • remove the listener explicitly when its wrapper unmounts
  • remove the obsolete sidenav.js file and shell script tag
  • use Leptos re-exports for browser bindings and close the registry's Cargo dependency metadata
  • add browser coverage for normal shortcuts, editable targets, event arbitration, exact modifiers, and unmount/remount cleanup
  • synchronize the distributable registry source and update the changelog

Security impact

No network listeners, telemetry, remote state, permissions, or background data transfer were added. The change removes a globally loaded script and scopes the keyboard handler to the mounted component lifecycle.

Verification

PORT=3000 pnpm --dir e2e exec playwright test tests/components/sidenav.spec.ts --project=chromium --workers=1
# 9 passed

CARGO_ENCODED_RUSTFLAGS=$'-C\x1fsymbol-mangling-version=v0\x1f--cfg\x1ferase_components' cargo +nightly-2026-07-23 test -p registry --lib
# 35 passed

CARGO_ENCODED_RUSTFLAGS=$'-C\x1fsymbol-mangling-version=v0\x1f--cfg\x1ferase_components' cargo +nightly-2026-07-23 test --workspace --lib --bins --tests
# 254 passed

cargo +nightly-2026-07-23 test --bin ui
# 310 passed

CARGO_ENCODED_RUSTFLAGS=$'-C\x1fsymbol-mangling-version=v0\x1f--cfg\x1ferase_components' cargo +nightly-2026-07-23 check -p app --no-default-features --features ssr

CARGO_ENCODED_RUSTFLAGS=$'-C\x1fsymbol-mangling-version=v0\x1f--cfg\x1ferase_components' cargo +nightly-2026-07-23 leptos build

cargo +nightly-2026-07-23 fmt --all -- --check
leptosfmt --check app_crates/registry/src/ui/sidenav.rs
git diff --check

A clean standalone consumer fixture containing the distributed Sidenav source also passes cargo check with the dependencies resolved by ui init plus the registry-declared leptos_router and strum/derive dependencies.

The unrestricted cargo test --workspace reaches two pre-existing leptos_ui doctest failures (void references an undefined url, and one variants example omits the macro import). Both failures are outside this change; all workspace library, binary, integration, and unit tests pass.

Fixture and migration notes

  • no storage or data migrations
  • no production-like fixtures
  • registry Cargo metadata now declares the component's existing compile-time dependencies

Closes #28

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.

Replace sidenav.js with a Rust keyboard shortcut in SidenavWrapper

1 participant