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

Fix: Button block does not centers on the editor #17063

Merged
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
4 changes: 0 additions & 4 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ import {
const { getComputedStyle } = window;

const applyFallbackStyles = withFallbackStyles( ( node, ownProps ) => {
if ( node ) {
node.classList.add( 'wp-block-button-wrapper' );
}

const { textColor, backgroundColor } = ownProps;
const backgroundColorValue = backgroundColor && backgroundColor.color;
const textColorValue = textColor && textColor.color;
Expand Down
7 changes: 6 additions & 1 deletion packages/block-library/src/button/editor.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.block-editor-block-list__block[data-type="core/button"] {
&[data-align="center"] {
text-align: center;
div[data-block] {
margin-left: auto;
margin-right: auto;
}
}

&[data-align="right"] {
Expand Down Expand Up @@ -76,6 +80,7 @@
}
}

.wp-block-button-wrapper {
// Display "table" is used because the button container should only wrap the content and not takes the full width.
div[data-type="core/button"] div[data-block] {
display: table;
}