From 2c8fb689624233419744c78155bb79ebf2f4a8ce Mon Sep 17 00:00:00 2001 From: Nikita Fedorov Date: Fri, 10 Jul 2026 06:11:43 +0500 Subject: [PATCH] fix: preserve plugin-set key images across profile re-renders Key.svelte kept a plugin-set image only in the component-local `slot`, while the bound `inslot` stayed on the profile's loaded instance. A grid re-render (`profile = profile` after create/move/paste in DeviceView) re-runs `$: update(inslot)` for every key -- safe_not_equal treats an identical object reference as changed -- and the unconditional `slot = inslot` reset the key back to the loaded image. Guard `update()` so it only resets `slot` when the bound reference actually changed, keeping the one-way `inslot`/`slot` design intact: an untouched key early-returns and keeps its `slot`, while a genuine change (a fresh instance in the profile, or the update_state listener) still applies. --- src/components/Key.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Key.svelte b/src/components/Key.svelte index 9e35006f..89745fe7 100644 --- a/src/components/Key.svelte +++ b/src/components/Key.svelte @@ -27,8 +27,11 @@ // One-way binding for slot data. export let inslot: ActionInstance | null; let slot: ActionInstance | null; + let lastInslot: ActionInstance | null | undefined; const update = (inslot: ActionInstance | null) => { + if (inslot === lastInslot) return; if (inslot && context && inslot.context.split(".")[0] != context.device) return; + lastInslot = inslot; slot = inslot; }; $: update(inslot);