[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:
parent
0364e9c463
commit
5ba6d4d0b0
1 changed files with 2 additions and 2 deletions
|
@ -31,7 +31,7 @@ export function defaultSamm(units, inMm = true) {
|
||||||
export function menuCoreSettingsOnlyHandler({ updateHandler, current }) {
|
export function menuCoreSettingsOnlyHandler({ updateHandler, current }) {
|
||||||
return function (path, part) {
|
return function (path, part) {
|
||||||
// Is this a reset?
|
// 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
|
// add or remove the part from the set
|
||||||
let newParts = new Set(current || [])
|
let newParts = new Set(current || [])
|
||||||
|
@ -39,7 +39,7 @@ export function menuCoreSettingsOnlyHandler({ updateHandler, current }) {
|
||||||
else newParts.add(part)
|
else newParts.add(part)
|
||||||
|
|
||||||
// if the set is now empty, reset
|
// 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
|
// otherwise use the new set
|
||||||
else newParts = [...newParts]
|
else newParts = [...newParts]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue