fix(tauri-app): NavRail click → view switch via callback prop
The `bind:current={view}` pattern in NavRail did not propagate
clicks to the parent's $state. Svelte 5's $bindable on this
runtime is flakey and on this particular build (Tauri 2.11 +
svelte 5.x) the setter was never invoked when a button was
clicked, so the view state stayed 'home' no matter which rail
button the user pressed. The user reported 'search tut sich nix
genau auch bei compose etc.'
Replace with explicit callback prop:
let { view = 'home', on_select } = $props();
onclick={() => on_select?.(item.id)}
The parent then mutates its own `view` rune directly via the
arrow function — Svelte tracks this unconditionally regardless of
runtime-specific bindable semantics.
Includes a vitest regression test that mounts a real Svelte
component harness (jsdom) and asserts that click events on each
rail button flip the parent's `view` and update the .active
class — so any future regression is caught in CI rather than at
the Tauri app window.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// Vitest config — enable jsdom for component tests that need a DOM.
|
||||
// We resolve the "browser" condition so `import { mount } from "svelte"`
|
||||
// picks up the client entry (index-client.js), not the server entry
|
||||
// (index-server.js) — the server build throws if you try to mount
|
||||
// a component in it.
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svelte({ hot: false })],
|
||||
resolve: {
|
||||
conditions: ["browser"],
|
||||
},
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
globals: false,
|
||||
include: ["src/**/*.test.ts"],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user