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

Tag Cloud Block: Prevent block support styles and additional CSS classes from being printed twice #44439

Merged
merged 6 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@import "./social-links/editor.scss";
@import "./spacer/editor.scss";
@import "./table/editor.scss";
@import "./tag-cloud/editor.scss";
@import "./template-part/editor.scss";
@import "./text-columns/editor.scss";
@import "./video/editor.scss";
Expand Down
11 changes: 10 additions & 1 deletion packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
setAttributes( updateObj );
};

const serverSideRenderAttirbutes = {
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
...attributes,
className: undefined,
style: {
...attributes.style,
spacing: undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If border support is added in the future, it will be necessary to write border: undefined here.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is an open PR adding typography supports to the Tag Cloud block. This would need updating here, in that PR, or immediately after it lands.

This is probably further justification that we should move the logic for stripping block support related attributes for <ServerSideRender> as suggested over on the PR doing this for the Archive block.

},
};

const inspectorControls = (
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
Expand Down Expand Up @@ -170,7 +179,7 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
<ServerSideRender
key="tag-cloud"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that only this block has a key prop among the blocks using the ServerSideRender component.
But since the key prop is not accepted by the ServerSideRender component, I removed it.

block="core/tag-cloud"
attributes={ attributes }
attributes={ serverSideRenderAttirbutes }
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
/>
</div>
</>
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/tag-cloud/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wp-block-tag-cloud {
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added according to #43465, but will revert if this fix is not needed now.

}