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

Nesting groups with non-default tagName generates unexpected HTML #37669

Closed
hteumeuleu opened this issue Dec 30, 2021 · 3 comments
Closed

Nesting groups with non-default tagName generates unexpected HTML #37669

hteumeuleu opened this issue Dec 30, 2021 · 3 comments

Comments

@hteumeuleu
Copy link

Description

When nesting a Group block inside another Group block with a non-default tagName attribute, the generated HTML seems wrong and unexpected.

Keeping the default tagName, the result of such blocks would be:

<div class="wp-block-group">
	<div class="wp-block-group__inner-container">
		<div class="wp-block-group">
			<div class="wp-block-group__inner-container">
				<p>Lorem ipsum.</p>
			</div>
		</div>
	</div>
</div>

Using a non-default tagName for the first Group (for example choosing <aside>), the result is the following:

<aside class="wp-block-group">
	<div class="wp-block-group">
		<div class="wp-block-group__inner-container">
			<div class="wp-block-group__inner-container">
				<p>Lorem ipsum.</p>
			</div>
		</div>
	</div>
</aside>

Notice how the .wp-block-group__inner-container divs are nesting in one another, instead of being direct children of each .wp-block-group element. The expected HTML here would have been:

<aside class="wp-block-group">
	<div class="wp-block-group__inner-container">
		<div class="wp-block-group">
			<div class="wp-block-group__inner-container">
				<p>Lorem ipsum.</p>
			</div>
		</div>
	</div>
</aside>

Step-by-step reproduction instructions

  1. Add a "Group" block.
  2. In the advanced panel of this block, change its "HTML element" value to anything other than the default (<div>) option. For example here, I'll pick <aside>.
  3. Inside this first group, add another "Group" block.
  4. Inside this second nested group, add a "Paragraph" block with "Lorem ipsum" in it.

Screenshots, screen recording, code snippet

Screenshot showing the first group block with a non-default tagName attribute

Environment info

  • WordPress 5.8.2 default installation with the Twenty Twenty-One theme, no plugins
  • Firefox 96.0b10
  • macOS 12.0.1

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

@Andrew-Starr
Copy link

I see you do not have Gutenberg installed, and in the latest version (and I assume in upcoming core WP 5.9 also) the inner element <div class="wp-block-group__inner-container"> is no longer used, and this issue will effectively be fixed.

The resulting HTML would be correctly nested like so:

<aside class="wp-block-group">
	<div class="wp-block-group">
		<p>Lorem ipsum.</p>
	</div>
</aside>

@Mamaduka
Copy link
Member

@Andrew-Starr is correct. The issue was fixed via #36256 and will ship with WP 5.9.

@hteumeuleu
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants