From 5ba6d4d0b0d577987d4062c6c363c0bb714cdf19 Mon Sep 17 00:00:00 2001 From: Jonathan Haas Date: Fri, 18 Apr 2025 06:24:34 +0000 Subject: [PATCH] [react] fix: deselecting included parts (#259) Running `updateHandler(part, undefined)` will set the setting to null instead of removing/resetting it, which causes problems. Fixes #239 Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/259 Reviewed-by: Joost De Cock Co-authored-by: Jonathan Haas Co-committed-by: Jonathan Haas --- packages/react/components/Editor/lib/core-settings.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react/components/Editor/lib/core-settings.mjs b/packages/react/components/Editor/lib/core-settings.mjs index f93038e4ad5..3d51f0b2f1c 100644 --- a/packages/react/components/Editor/lib/core-settings.mjs +++ b/packages/react/components/Editor/lib/core-settings.mjs @@ -31,7 +31,7 @@ export function defaultSamm(units, inMm = true) { export function menuCoreSettingsOnlyHandler({ updateHandler, current }) { return function (path, part) { // Is this a reset? - if (part === undefined || part === '__UNSET__') return updateHandler(path, part) + if (part === undefined || part === '__UNSET__') return updateHandler(path, '__UNSET__') // add or remove the part from the set let newParts = new Set(current || []) @@ -39,7 +39,7 @@ export function menuCoreSettingsOnlyHandler({ updateHandler, current }) { else newParts.add(part) // if the set is now empty, reset - if (newParts.size < 1) newParts = undefined + if (newParts.size < 1) return updateHandler(path, '__UNSET__') // otherwise use the new set else newParts = [...newParts]