Skip to content

AI-native design editor. Open-source Figma alternative.

fix(fig): preserve nested text overrides

Danila Poyarkov7d0f9746ee04
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b609a58f..e1217585d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
- Restore native copy, cut, and paste shortcuts in desktop text inputs while preserving design clipboard handling on the canvas.
- Remove the permanent CORS configuration action from cloud-storage settings and report connection results through standard toasts with clear browser-specific guidance.
- Complete translated app, accessibility, font, color, collaboration, import, connection-test, and browser fallback text across all supported locales, and keep the document language synchronized with the selected locale.
+- Preserve effective nested instance text overrides when importing complex Figma component hierarchies. (#102)
- Preserve circles, ellipses, rectangles, lines, polylines, and polygons supplied as JSX children of inline SVG elements. (#452)
## 0.14.0 - 2026-08-10
diff --git a/packages/fig/src/instance-overrides/sync/propagate.ts b/packages/fig/src/instance-overrides/sync/propagate.ts
index 027c35972..fe321cf5e 100644
--- a/packages/fig/src/instance-overrides/sync/propagate.ts
+++ b/packages/fig/src/instance-overrides/sync/propagate.ts
@@ -1,6 +1,6 @@
import type { SceneGraph } from '@open-pencil/scene-graph'
-import type { ProtectionMap } from '../patches'
+import { isFieldProtected, type ProtectionMap } from '../patches'
import { buildClonesMap, syncChildrenDeep } from './clones'
import { syncNodeProps } from './fields'
import { indexCloneSubtree, remapRepopulatedChildSources, snapshotChildSources } from './sources'
@@ -129,6 +129,15 @@ export function propagateOverridesTransitively(
if (!node) continue
if (skip.has(cloneId)) {
+ // A directly overridden clone may still inherit effective text from an
+ // overridden source. Respect its own text override when present.
+ if (
+ source.type === 'TEXT' &&
+ node.type === 'TEXT' &&
+ !isFieldProtected(protections, node.id, 'text')
+ ) {
+ graph.updateNode(node.id, { text: source.text })
+ }
syncQueue.push(cloneId)
continue
}
diff --git a/packages/fig/tests/instance-overrides.test.ts b/packages/fig/tests/instance-overrides.test.ts
index 779edb900..61655a01c 100644
--- a/packages/fig/tests/instance-overrides.test.ts
+++ b/packages/fig/tests/instance-overrides.test.ts
@@ -2,6 +2,8 @@ import { describe, expect, test } from 'bun:test'
import { SceneGraph } from '@open-pencil/scene-graph'
+import { propagateOverridesTransitively } from '../src/instance-overrides/sync/propagate'
+
import {
populateAndApplyOverrides,
protectField,
@@ -407,6 +409,33 @@ describe('@open-pencil/fig instance interpretation', () => {
expect(graph.getNode(target.id)?.boundVariables).toEqual({ width: 'width-var' })
})
+ test('inherits effective text on a structurally protected clone', () => {
+ const graph = new SceneGraph()
+ const pageId = graph.getPages()[0].id
+ const component = graph.createNode('COMPONENT', pageId)
+ const source = graph.createNode('TEXT', component.id, {
+ text: 'Effective label'
+ })
+ const instance = graph.createNode('INSTANCE', pageId, { componentId: component.id })
+ graph.populateInstanceChildren(instance.id, component.id, 'fig-import')
+ const clone = graph.getChildren(instance.id)[0]
+ graph.updateNode(clone.id, { text: 'Default label' })
+ const protections: ProtectionMap = new Map()
+ protectField(protections, clone.id, 'width')
+
+ propagateOverridesTransitively(
+ graph,
+ new Set([source.id, clone.id]),
+ new Set(),
+ new Map(),
+ undefined,
+ undefined,
+ protections
+ )
+
+ expect(graph.getNode(clone.id)?.text).toBe('Effective label')
+ })
+
test('preserves protected text while synchronizing other fields', () => {
const graph = new SceneGraph()
const pageId = graph.getPages()[0].id