1
0
Fork 0

[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 <joostdecock@noreply.codeberg.org>
Co-authored-by: Jonathan Haas <haasjona@gmail.com>
Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
Jonathan Haas 2025-04-18 06:24:34 +00:00 committed by Joost De Cock
parent 0364e9c463
commit 5ba6d4d0b0

View file

@ -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]