File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -42,14 +42,17 @@ export class Element {
4242 if ( this . css [ 'width' ] ?. endsWith ( 'px' ) && this . node . parent ) {
4343 if (
4444 this . node . parent . type === 'SECTION' ||
45- this . node . parent . type === 'PAGE'
45+ this . node . parent . type === 'PAGE' ||
46+ // inline case
47+ ( this . node . parent as any ) . layoutSizingHorizontal == 'HUG'
4648 )
4749 delete this . css [ 'width' ]
4850 else if (
4951 'width' in this . node . parent &&
5052 this . node . width === this . node . parent . width
51- )
53+ ) {
5254 this . css [ 'width' ] = '100%'
55+ }
5356 }
5457 // Image has not padding
5558 return this . css
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ function createNode(
1212 fills,
1313 parent,
1414 layoutPositioning = 'AUTO' ,
15+ layoutSizingHorizontal,
1516 ...props
1617 } : {
1718 [ _ : string ] : any
@@ -26,6 +27,7 @@ function createNode(
2627 type,
2728 getCSSAsync : async ( ) => props ,
2829 exportAsync : async ( ) => '<svg>\n<path/>\n</svg>' ,
30+ layoutSizingHorizontal,
2931 textStyleId,
3032 parent,
3133 characters,
@@ -676,4 +678,18 @@ describe('Element', () => {
676678 )
677679 } )
678680 } )
681+
682+ describe ( 'Render' , ( ) => {
683+ it ( 'should remove width when parent is HUG' , async ( ) => {
684+ const element = createElement ( 'FRAME' , {
685+ layoutSizingHorizontal : 'HUG' ,
686+ children : [
687+ createNode ( 'INSTANCE' , {
688+ width : '1920px' ,
689+ } ) ,
690+ ] ,
691+ } )
692+ expect ( await element . render ( ) ) . toEqual ( '<Box>\n <Box />\n</Box>' )
693+ } )
694+ } )
679695} )
You can’t perform that action at this time.
0 commit comments