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

Button (singular) block can't be centered #42499

Closed
cecilearkay opened this issue May 20, 2020 · 13 comments
Closed

Button (singular) block can't be centered #42499

cecilearkay opened this issue May 20, 2020 · 13 comments
Labels
Blocks Editor blocks, aka Gutenberg blocks, plugins, and extensions [Type] Bug User Report This issue was created following a WordPress customer report

Comments

@cecilearkay
Copy link

Unlike the buttons (plural) block, the button block can't be centered. It can be aligned to the right, but will remain on the left if you choose to center it. It only happens on WordPress.com, whether the site is Simple or Atomic. It doesn't happen on .org as far as I could see.

Steps to reproduce

Although it can't be added by looking it up in the list of available blocks, the button block can be added manually with the code editor or by choosing a layout,

  1. Create a new page and choose a layout, like one of the About layouts, which comes with the single button block,
  2. Center the button using the alignment option,
  3. Preview/publish and notice it's still aligned to the left.

What I expected

The button to be centered.

What happened instead

The button remains on the left.

Screenshot / Video

Screen Capture on 2020-05-20 at 21-39-04

Workaround

Add the following CSS to My Site > Design > Customize > Additional CSS:

.wp-block-button.btn-centered {
	display: block;
	text-align: center;
}

Add the following class to the Advanced module of the button: btn-centered

@cecilearkay cecilearkay added the Blocks Editor blocks, aka Gutenberg blocks, plugins, and extensions label May 20, 2020
@xpurichan
Copy link

Getting lots of reports about this in HC and ZD which we can see in Slack. I got another report in 21276293-hc.

Another solution is to convert the "button" block to the new "buttons" block, center-align works there.

@khristiansnyder
Copy link

khristiansnyder commented May 21, 2020

Had this in 12287038-hc

  • Gutenberg: 8.1.0-wpcom
  • CoBlocks: 1.23.0
  • wpcom-FSE: 110334318

Used this CSS to center user's blocks as they wanted all blocks on their site centered:

.wp-block-button {
    text-align: center;
}

@davoraltman
Copy link

Another case in 21821402-hc

@davipontesblog
Copy link
Contributor

This block (Button) has been deprecated in favor of the new block "Buttons", for a few months now, but some sites still have the old block and it's causing this issue. @lsl mentioned this is being tracked here in the Gutenberg repo: WordPress/gutenberg#21509

Solution: Convert the block to "Buttons", and alignment works.

@zdenys
Copy link
Contributor

zdenys commented Jun 13, 2020

Just wanted to link the conversation where I first reported the above issue too p1591724116387100-slack-CRNF6A9DX

@LauraSWP
Copy link

LauraSWP commented Jun 22, 2020

I am having the same issue with 2 users.
81746664-30f47d80-94a7-11ea-972d-c31a779a06d1

And this one is using the Buttons block, which should work but it doesn't:
button

@zdenys
Copy link
Contributor

zdenys commented Jun 23, 2020

@LauraSWP, for the second case:

And this one is using the Buttons block, which should work but it doesn't:

Make sure to do this:

To change a button’s alignment, select the entire Buttons block first and then align left, center, or right from the toolbar.

as mentioned and illustrated in https://wordpress.com/support/wordpress-editor/blocks/buttons-block/#aligning-buttons

@lsl
Copy link
Contributor

lsl commented Jun 25, 2020

And this one is using the Buttons block, which should work but it doesn't:

This looks like it has nested buttons blocks, iirc the inner buttons should not have an alignment option.

Are you able to get a hold of the raw gutenberg html/markup from the code editor?

@TeniCola
Copy link

TeniCola commented Aug 9, 2020

Hi all! My team encountered this same issue with centering the Button block during our team's virtual meetup, where we were using Gutenberg for our DIFM project. Context in team master thread: p6knfs-29V-p2

The CSS solution is good to know in the future, as well as converting the Button block to Buttons instead, so we'll be mindful of this moving forward. Just adding a note here that the issue came up for some new sites we had created during our team project.

@lsl
Copy link
Contributor

lsl commented Aug 11, 2020

Just adding a note here that the issue came up for some new sites we had created during our team project.

@ramonjd maybe headstart content needs updating?

@ramonjd
Copy link
Member

ramonjd commented Aug 11, 2020

Just adding a note here that the issue came up for some new sites we had created during our team project.

Thanks for the ping.

@TeniCola Were those sites created via wordpress.com/start or wordpress.com/new?

If wordpress.com/new, which "design" did you select?

If it's something to do with the initial code we use to create pages in onboarding it's definitely something we can look into further. 👍

@liviopv
Copy link

liviopv commented Dec 4, 2020

@ramonjd I made some testings and found out that the old version of the Button Block is present on some themes starter content, like Exford. While it still keeps the alignment while Exform is active, the alignment breaks as soon as the user switches themes.

Reported the issue in Exford here: Automattic/themes#2888

@kristenzuck kristenzuck added the User Report This issue was created following a WordPress customer report label Apr 29, 2021
@arunsathiya
Copy link
Contributor

I see that there are two things here.

Old Button block

One way to find this block is by activating Exford and editing the demo homepage that it generates. It shows the old Button block throughout that page. It's not clear if we have plans to change that to the newer Buttons block, and if we would do that for all affected sites. I asked about it here.

In the meantime, I see that the old Button block's alignment works fine now. This is how things look when left-aligned:

image

image

And when centered:

image

image

Newer Buttons block

I can see that the center alignment option is available only on the inner Button block. The parent block does not. The inner block's setting works fine:

image

image

Conclusion

I'll close this report for now, as it has been nearly two years and the Gutenberg and themes experience has evolved a lot since. The newer Buttons block should be the only available option these days.

If affected customers reach out, we should help them move to the newer Buttons block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocks Editor blocks, aka Gutenberg blocks, plugins, and extensions [Type] Bug User Report This issue was created following a WordPress customer report
Projects
None yet
Development

No branches or pull requests