Skip to content

Gallery block with class columns-default should also output columns-x  #56884

Open

Description

Description

When adding a new gallery block instance and not changing the columns, the container element includes the class "columns-default", but does not include a class for the number of columns that the default is set to (for example, "columns-3"). If you switch the columns manually to a number other than the default (3) and then switch back to the 3. The instance will now be output with the class "columns-3" but will not include "columns-default".

Arguably the initial instance should display "columns-default" and "columns-3" to make styling easier, and to be of use to and custom JavaScript that needs to determine the number of columns the gallery block is intended to display. Also, after the column count being changed to a value other than 3 and then set to 3 again, the class "columns-default" should probably be added back.

Step-by-step reproduction instructions

  1. Add an instance of the gallery block to a page or post.
  2. Add an image.
  3. Leave the columns count the same (3 in a clean install).
  4. Publish the page or post.
  5. View the page.
  6. Inspect the page's HTML structure.
  7. The wp-block-gallery instance will include the class "columns-default" but not the class "columns-3"
  8. Edit the page/post
  9. Change the columns to a value other than the default.
  10. Save the page/post.
  11. Change the columns back to the default of 3.
  12. Save the page or post.
  13. Inspect the page's HTML structure.
    1. The wp-block-gallery instance will include the class "columns-3" but not the class "columns-default".

Screenshots, screen recording, code snippet

No response

Environment info

Wordpress: 6.4.2
Gutenberg: 16.2-16.7 (as per https://developer.wordpress.org/block-editor/contributors/versions-in-wordpress/)

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

Yes

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

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Block] GalleryAffects the Gallery Block - used to display groups of images[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions