Fix DSD resolution for swapped instance children

After an instance swap, the DSD guidPath still references the
pre-swap slot's overrideKey (e.g. bold icon), but the actual child
is the swapped-in component (e.g. code-2). resolveOverrideTarget
couldn't find the target because the child's componentId no longer
matched the guidPath element.

When findNodeByComponentId fails, fall back to the single child
of the parent node — after a swap, it occupies the same slot.

Fixes cropped toolbar icons (bold, italic, underline, strikethrough,
link, lists, code) in the WYSIWYG editor.
This commit is contained in:
Danila Poyarkov 2026-03-14 12:47:51 +03:00
parent f70338d18e
commit d93c4752cb

View file

@ -129,8 +129,21 @@ export function resolveOverrideTarget(ctx: OverrideContext, instanceId: string,
if (current?.componentId === remapped) continue
const found = findNodeByComponentId(ctx, currentId, remapped)
if (!found) return null
currentId = found
if (found) {
currentId = found
continue
}
// After an instance swap, the child's componentId points to the new
// component, not the one referenced by the guidPath. Fall back to the
// single child of a swapped instance — it occupies the same slot.
const parent = ctx.graph.getNode(currentId)
if (parent?.childIds.length === 1) {
currentId = parent.childIds[0]
continue
}
return null
}
return currentId
}