Skip to content

Commit

Permalink
Include cascading properties in Navigation deprecation (#36432)
Browse files Browse the repository at this point in the history
* Include cascading properties in nav deprecation

* Update fixtures
  • Loading branch information
tellthemachines authored and noisysocks committed Nov 30, 2021
1 parent 6d3bd91 commit 20f1458
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
19 changes: 10 additions & 9 deletions packages/block-library/src/navigation/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@ const migrateWithLayout = ( attributes ) => {
return attributes;
}

const { itemsJustification, orientation } = attributes;

const updatedAttributes = {
...attributes,
};
const {
itemsJustification,
orientation,
...updatedAttributes
} = attributes;

if ( itemsJustification || orientation ) {
Object.assign( updatedAttributes, {
layout: {
type: 'flex',
justifyContent: itemsJustification || 'left',
orientation: orientation || 'horizontal',
setCascadingProperties: 'true',
...( itemsJustification && {
justifyContent: itemsJustification,
} ),
...( orientation && { orientation } ),
},
} );
delete updatedAttributes.itemsJustification;
delete updatedAttributes.orientation;
}

return updatedAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"overlayMenu": "mobile",
"layout": {
"type": "flex",
"justifyContent": "left",
"setCascadingProperties": "true",
"orientation": "horizontal"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:navigation {"layout":{"type":"flex","justifyContent":"left","orientation":"horizontal"}} -->
<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":"true","orientation":"horizontal"}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"fontFamily": "cambria-georgia",
"layout": {
"type": "flex",
"justifyContent": "left",
"setCascadingProperties": "true",
"orientation": "horizontal"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:navigation {"overlayMenu":"never","fontFamily":"cambria-georgia","layout":{"type":"flex","justifyContent":"left","orientation":"horizontal"}} /-->
<!-- wp:navigation {"overlayMenu":"never","fontFamily":"cambria-georgia","layout":{"type":"flex","setCascadingProperties":"true","orientation":"horizontal"}} /-->
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"overlayMenu": "never",
"layout": {
"type": "flex",
"setCascadingProperties": "true",
"justifyContent": "center",
"orientation": "vertical"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:navigation {"overlayMenu":"never","layout":{"type":"flex","justifyContent":"center","orientation":"vertical"}} /-->
<!-- wp:navigation {"overlayMenu":"never","layout":{"type":"flex","setCascadingProperties":"true","justifyContent":"center","orientation":"vertical"}} /-->
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"layout": {
"type": "flex",
"justifyContent": "left",
"setCascadingProperties": "true",
"orientation": "horizontal"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:navigation {"style":{"typography":{"textTransform":"lowercase","textDecoration":"line-through","fontStyle":"italic","fontWeight":"100"}},"layout":{"type":"flex","justifyContent":"left","orientation":"horizontal"}} -->
<!-- wp:navigation {"style":{"typography":{"textTransform":"lowercase","textDecoration":"line-through","fontStyle":"italic","fontWeight":"100"}},"layout":{"type":"flex","setCascadingProperties":"true","orientation":"horizontal"}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->

0 comments on commit 20f1458

Please sign in to comment.