From a2f2076231e9c95121a8ee3c67053342b69eb146 Mon Sep 17 00:00:00 2001 From: Guilhem Date: Fri, 4 Apr 2025 18:11:14 +0100 Subject: [PATCH] fix(frontend): proper each block binding + better app settings reactivity (#5568) * fix: properly bind to array elements in Svelte each loops This commit fixes an issue where binding directly to loop variables in Svelte's #each loops doesn't properly update the original array. Instead of binding directly to the loop variable, we now bind to the array elements using index variables. The pattern used is: - Change: {#each arr as el} -> {#each arr as _, index} - Change: bind:value={el} -> bind:value={arr[index]} Modified files: - frontend/src/lib/components/ArrayTypeNarrowing.svelte - frontend/src/lib/components/apps/editor/AppInputs.svelte - frontend/src/lib/components/flows/content/FlowModuleWrapper.svelte * better app settings panel reactivity --------- Co-authored-by: Ruben Fiszel Co-authored-by: HugoCasa --- .../lib/components/ArrayTypeNarrowing.svelte | 13 +- .../src/lib/components/OAuthSetting.svelte | 4 +- .../apps/components/helpers/onObjChange.ts | 15 -- .../components/apps/editor/AppInputs.svelte | 14 +- .../apps/editor/SettingsPanel.svelte | 226 ++++++++++++++---- .../lib/components/apps/editor/appUtils.ts | 150 +++++++++--- .../settingsPanel/ComponentPanel.svelte | 6 +- .../script/BackgroundScriptSettings.svelte | 6 +- .../flows/content/FlowModuleWrapper.svelte | 4 +- 9 files changed, 323 insertions(+), 115 deletions(-) delete mode 100644 frontend/src/lib/components/apps/components/helpers/onObjChange.ts diff --git a/frontend/src/lib/components/ArrayTypeNarrowing.svelte b/frontend/src/lib/components/ArrayTypeNarrowing.svelte index 8e2fe827c3..2d37233086 100644 --- a/frontend/src/lib/components/ArrayTypeNarrowing.svelte +++ b/frontend/src/lib/components/ArrayTypeNarrowing.svelte @@ -25,8 +25,8 @@ itemsType?.type != 'string' ? itemsType?.type : Array.isArray(itemsType?.enum) - ? 'enum' - : 'string' + ? 'enum' + : 'string' let schema = { properties: itemsType?.properties || {}, @@ -105,16 +105,17 @@