Make-cq-customizer-more-resilient (#560)

Was failing when initial values were missing
This commit was merged in pull request #560.
This commit is contained in:
Kurt Hutten
2021-10-16 03:59:19 +11:00
committed by GitHub
parent 50cd44cd76
commit bc1f12971d
2 changed files with 4 additions and 4 deletions

View File

@@ -304,7 +304,7 @@ function NumberParam({
if (typeof param.max === 'number') { if (typeof param.max === 'number') {
num = Math.min(param.max, num) num = Math.min(param.max, num)
} }
num = Number(num.toFixed(2)) num = Number((num || 0).toFixed(2))
localValueSetter(num) localValueSetter(num)
onChange(num) onChange(num)
} }

View File

@@ -41,21 +41,21 @@ export function CadQueryToCadhubParams(
type: 'number', type: 'number',
input: 'default-number', input: 'default-number',
...common, ...common,
initial: param.initial, initial: param.initial || 0,
} }
case 'string': case 'string':
return { return {
type: 'string', type: 'string',
input: 'default-string', input: 'default-string',
...common, ...common,
initial: param.initial, initial: param.initial || '',
} }
case 'boolean': case 'boolean':
return { return {
type: 'boolean', type: 'boolean',
input: 'default-boolean', input: 'default-boolean',
...common, ...common,
initial: param.initial, initial: param.initial || false,
} }
} }
}) })