WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.56k stars 4.22k forks source link

Align controls disappear when custom content and wide width reset on parent. #66389

Open tellthemachines opened 1 month ago

tellthemachines commented 1 month ago

Description

Removing the custom content and wide width values on a container block makes its children's Align toolbar button disappear.

Step-by-step reproduction instructions

  1. Add custom content and wide widths to a Group block containing a Columns block;
  2. Set the Columns block to align wide - up to here everything works as expected;
  3. Unset the custom content and wide widths on the parent Group;
  4. See that the Align control has now disappeared from the Columns block.

Screenshots, screen recording, code snippet

Image

Environment info

Gutenberg trunk.

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Please confirm which theme type you used for testing.

andrewserong commented 1 month ago

While testing this, I noticed that when resetting the content and wide sizes in the editor, the value stored in post content is an empty string (e.g. {"type":"constrained","contentSize":"","wideSize":""}}.). So I'm wondering if that's causing an issue for the code that detects the alignments?

I haven't had a chance to dig in further just yet, so just thought I'd share that in case anyone beats me to it 🙂

valerogarte commented 3 days ago

I tried to help, but I couldn't reproduce the issue as described. Here's what I did:

Step 1 - Add a Group Block with Columns Block inside it

Image

Step 2 - Set "Align Wide" for the Columns Block

Image

Step 3 - Disable Content Width on the Group Block

Image

Step 4 - Result: The alignment controls for the Columns Block are still visible, and everything seems to be working as expected.

Image