fix(scene-graph): preserve text instance overrides
This commit is contained in:
parent
7e325e4072
commit
01353e7ca7
|
|
@ -1,3 +1,4 @@
|
|||
import { recordInstanceOverride } from '@open-pencil/scene-graph'
|
||||
import type {
|
||||
SceneGraph,
|
||||
SceneNode,
|
||||
|
|
@ -137,7 +138,10 @@ export class FigmaNodeProxy {
|
|||
|
||||
private _update(changes: Partial<SceneNode>): void {
|
||||
assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])
|
||||
this[INTERNAL_GRAPH].updateNode(this[INTERNAL_ID], changes)
|
||||
const graph = this[INTERNAL_GRAPH]
|
||||
const id = this[INTERNAL_ID]
|
||||
graph.updateNode(id, changes)
|
||||
recordInstanceOverride(graph, id, Object.keys(changes))
|
||||
}
|
||||
|
||||
private _raw(): SceneNode {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,24 @@ describe('setting fills on an instance descendant', () => {
|
|||
expect(raw?.overrides[`${vector.id}:fills`]).toBe(true)
|
||||
})
|
||||
|
||||
test('preserves text edits on an instance descendant during resync', () => {
|
||||
const api = createAPI()
|
||||
const component = api.createComponent()
|
||||
const text = api.createText()
|
||||
text.characters = 'Default'
|
||||
component.appendChild(text)
|
||||
|
||||
const instance = component.createInstance()
|
||||
const instanceText = instance.children[0]
|
||||
if (!instanceText) throw new Error('instance text not found')
|
||||
instanceText.characters = 'Custom'
|
||||
|
||||
expect(api.graph.getNode(instance.id)?.overrides[`${instanceText.id}:text`]).toBe(true)
|
||||
text.characters = 'Updated default'
|
||||
api.graph.syncInstances(component.id)
|
||||
|
||||
expect(instanceText.characters).toBe('Custom')
|
||||
})
|
||||
test('does not record an override for a node with no instance ancestor', () => {
|
||||
const api = createAPI()
|
||||
const frame = api.createFrame()
|
||||
|
|
|
|||
Loading…
Reference in a new issue