fix(fig): tolerate empty component property assignments
This commit is contained in:
parent
5689eccc0c
commit
b0e9995e4c
|
|
@ -62,7 +62,10 @@ function applySwapProp(
|
|||
const swapId =
|
||||
propTextCharacters(val) ?? (val.guidValue ? guidToString(val.guidValue) : undefined)
|
||||
const newCompId = swapId ? ctx.guidToNodeId.get(swapId) : undefined
|
||||
if (!newCompId) return
|
||||
const currentCompId = ctx.graph.getNode(childId)?.componentId
|
||||
if (currentCompId && getComponentRoot(ctx, currentCompId) === getComponentRoot(ctx, newCompId)) {
|
||||
return
|
||||
}
|
||||
applyPatchAndMark(
|
||||
ctx,
|
||||
childId,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ export function propTextCharacters(value: ComponentPropValue): string | undefine
|
|||
return value.textValue?.characters ?? value.textDataValue?.characters
|
||||
}
|
||||
|
||||
function isEmptyPropValue(v: ComponentPropValue): boolean {
|
||||
function isEmptyPropValue(v: ComponentPropValue | undefined): boolean {
|
||||
if (!v) return true
|
||||
return (
|
||||
v.boolValue === undefined &&
|
||||
v.textValue === undefined &&
|
||||
|
|
@ -31,8 +32,9 @@ function resolveAssignmentValue(
|
|||
assignment: ComponentPropAssignment,
|
||||
key: string,
|
||||
resolveDefaults: boolean
|
||||
): ComponentPropValue {
|
||||
if (!isEmptyPropValue(assignment.value)) return assignment.value
|
||||
): ComponentPropValue | undefined {
|
||||
const value = assignment.value
|
||||
if (value && !isEmptyPropValue(value)) return value
|
||||
|
||||
const variableValue = assignment.varValue?.value
|
||||
if (variableValue?.symbolIdValue?.guid) return { guidValue: variableValue.symbolIdValue.guid }
|
||||
|
|
@ -53,7 +55,8 @@ export function assignmentsToValueMap(
|
|||
for (const assignment of assignments) {
|
||||
if (!assignment.defID) continue
|
||||
const key = guidToString(assignment.defID)
|
||||
valueByDef.set(key, resolveAssignmentValue(ctx, assignment, key, resolveDefaults))
|
||||
const value = resolveAssignmentValue(ctx, assignment, key, resolveDefaults)
|
||||
if (value) valueByDef.set(key, value)
|
||||
}
|
||||
return valueByDef
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export type ComponentPropValue = {
|
|||
|
||||
export interface ComponentPropAssignment {
|
||||
defID?: GUID
|
||||
value: ComponentPropValue
|
||||
value?: ComponentPropValue
|
||||
varValue?: {
|
||||
value?: {
|
||||
boolValue?: boolean
|
||||
|
|
|
|||
Loading…
Reference in a new issue