Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include cascading properties in Navigation deprecation #36432

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -26,22 +26,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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this property on a "layout" object mean? Sounds very weird to me?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it's coming from #36292 I'll check there.

"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 -->