From 7b8704963752f6fa7c9b96410c58030d3ec458d2 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Fri, 29 May 2026 12:24:18 +0200 Subject: [PATCH] fix(macros): keep commands from vanishing when reordering in the macro editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro command list assigned svelte-dnd-action's raw consider/finalize items (including the library's internal shadow placeholder) straight to `commands`, and only filtered the placeholder out of the {#each}. With few items, a command could linger in state as the placeholder and then get filtered out of the render — i.e. disappear when reordering via drag. Mirror the fix already applied to the Settings choice list in #883: strip the SHADOW_PLACEHOLDER_ITEM_ID entry in handleConsider and handleSort before assigning to `commands`. (CommandList was the only dndzone list missing this.) Verified by hand in the dev vault: reordering with 2+ commands no longer drops an item, and order persists. build + svelte-check clean; unit tests pass. --- src/gui/MacroGUIs/CommandList.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/MacroGUIs/CommandList.svelte b/src/gui/MacroGUIs/CommandList.svelte index cbbdc6c5..7ea4f4e1 100644 --- a/src/gui/MacroGUIs/CommandList.svelte +++ b/src/gui/MacroGUIs/CommandList.svelte @@ -60,7 +60,12 @@ const asConditional = (c: ICommand) => c as IConditionalCommand; function handleConsider(e: CustomEvent) { let { items: newItems } = e.detail; - commands = newItems as ICommand[]; + // Drop svelte-dnd-action's internal shadow placeholder so a command can't + // linger in state and vanish on reorder (ghost gap) — mirrors the Settings + // choice list fix (#883). + commands = (newItems as ICommand[]).filter( + (c) => c.id !== SHADOW_PLACEHOLDER_ITEM_ID + ); } function handleSort(e: CustomEvent) { @@ -69,7 +74,9 @@ const asConditional = (c: ICommand) => c as IConditionalCommand; info: { source }, } = e.detail; - commands = newItems as ICommand[]; + commands = (newItems as ICommand[]).filter( + (c) => c.id !== SHADOW_PLACEHOLDER_ITEM_ID + ); if (source === SOURCES.POINTER) { dragDisabled = true;