AI-native design editor. Open-source Figma alternative.
fix(layout): preserve imported Figma line geometry
Danila Poyarkov270e3c1e5716
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc2e8a48b..eebfe5e8b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -72,6 +72,8 @@### Fixed+- Preserve imported Figma divider-line geometry during auto-layout recomputation, preventing half-pixel shifts on save and reload.+- Make published package export conditions resolve to files included in npm tarballs.- Use the user's home directory as the default MCP file root on Windows, avoiding the caller's unreliable working directory.- Open legacy raw `.fig` files that store the Kiwi document and thumbnail without a ZIP wrapper. (#582)diff --git a/packages/core/src/layout/apply.ts b/packages/core/src/layout/apply.tsindex 0e627ed5e..bcfd82edf 100644--- a/packages/core/src/layout/apply.ts+++ b/packages/core/src/layout/apply.ts@@ -101,9 +101,9 @@ function updateChildFromYoga(graph: SceneGraph, child: SceneNode, yogaChild: Yogif (!child.visible || child.layoutPositioning === 'ABSOLUTE') returnconst preservesImportedFrameGeometry =- child.type === 'FRAME' &&child.source.format === 'fig' &&- frameSourceIsFig(graph, child.parentId)+ frameSourceIsFig(graph, child.parentId) &&+ (child.type === 'FRAME' || child.type === 'LINE')const preservesImportedPosition =preservesImportedFrameGeometry ||(child.source.format === 'fig' && Math.abs(child.rotation) > 0.001)diff --git a/tests/engine/layout/auto-layout/layout/imported-derived.test.ts b/tests/engine/layout/auto-layout/layout/imported-derived.test.tsindex 28aadbe14..0787193fd 100644--- a/tests/engine/layout/auto-layout/layout/imported-derived.test.ts+++ b/tests/engine/layout/auto-layout/layout/imported-derived.test.ts@@ -4,6 +4,31 @@ import { computeAllLayouts, SceneGraph } from '@open-pencil/core'import { getAbsolutePositionFull } from '@open-pencil/scene-graph'describe('imported auto-layout bounds', () => {+ test('preserves direct imported line geometry inside imported parents', () => {+ const graph = new SceneGraph()+ const page = graph.getPages()[0]+ const frame = graph.createNode('FRAME', page.id, {+ width: 320,+ height: 1,+ layoutMode: 'VERTICAL',+ primaryAxisSizing: 'FIXED',+ counterAxisSizing: 'FIXED',+ source: { ...page.source, format: 'fig', id: '1:1' }+ })+ const line = graph.createNode('LINE', frame.id, {+ x: 0,+ y: 1,+ width: 320,+ height: 0,+ layoutAlignSelf: 'STRETCH',+ source: { ...page.source, format: 'fig', id: '1:2' }+ })++ computeAllLayouts(graph)++ expect(graph.getNode(line.id)).toMatchObject({ x: 0, y: 1, width: 320, height: 0 })+ })+test('preserves visible hug container bounds when hidden children would collapse layout', () => {const graph = new SceneGraph()const page = graph.getPages()[0]