Skip to content

Commit 0425a31

Browse files
committed
fix(ui): mergeDefaultFont distinguishes cleared input from absent key
Using `??` to merge the patch into the current value collapsed two distinct states: "this key was not in the patch" and "the user just cleared this input". The latter passes `{ height: undefined }`, but `undefined ?? current.height` falls through to the old value, so clearing the height field had no effect on stored defaultFont. Replaces `??` with an `in` check so an explicit `undefined` overrides current.
1 parent bb7a613 commit 0425a31

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/components/Properties/PropertiesPanel.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,11 @@ function mergeDefaultFont(
481481
current: LabelConfig["defaultFont"],
482482
patch: { fontId?: string; height?: number },
483483
): LabelConfig["defaultFont"] {
484-
const fontId = patch.fontId ?? current?.fontId ?? "";
485-
const height = patch.height ?? current?.height;
484+
// `in` distinguishes "key absent from patch" (keep current value) from
485+
// "key set to undefined" (user just cleared the input). `??` would conflate
486+
// the two and silently keep the old value when the user clears a field.
487+
const fontId = "fontId" in patch ? patch.fontId : current?.fontId;
488+
const height = "height" in patch ? patch.height : current?.height;
486489
if (!fontId || height === undefined) return undefined;
487490
return { fontId, height };
488491
}

0 commit comments

Comments
 (0)