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

HTML structure of navigation blocks differs between editor and front #61170

Open
inc2734 opened this issue Apr 27, 2024 · 0 comments
Open

HTML structure of navigation blocks differs between editor and front #61170

inc2734 opened this issue Apr 27, 2024 · 0 comments
Labels
[Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended

Comments

@inc2734
Copy link
Contributor

inc2734 commented Apr 27, 2024

Description

HTML structure of navigation blocks differs between editor and front.

This makes it difficult to adjust the CSS so that it looks the same in both HTML versions when it is attempted to be overridden.

Since the HTML structure in the editor feels more straightforward, it seems to me that it would be better to adapt the front end to it as well.

Step-by-step reproduction instructions

  1. Go to site editor.
  2. Add to sub navigation block and button block to navigation block.

Screenshots, screen recording, code snippet

スクリーンショット 2024-04-27 10 16 10

Editor

<nav class="items-justified-right is-responsive is-layout-flex is-horizontal is-content-justification-right wp-block-navigation">
	<button type="button" class="wp-block-navigation__responsive-container-open">
		...
	</button>
	<div class="wp-block-navigation__responsive-container">
		<div class="wp-block-navigation__responsive-close">
			<div class="wp-block-navigation__responsive-dialog">
				<button type="button" class="wp-block-navigation__responsive-container-close">
					...
				</button>
				<div class="wp-block-navigation__responsive-container-content">
					<div class="wp-block-navigation__container">
						<ul class="has-block-overlay wp-block-page-list wp-block-page-list">
							<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Sample Page</a></li>
							<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Blog</a></li>
							
							
							<li class="wp-block-pages-list__item has-child wp-block-navigation-item open-on-hover-click">
								<a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Home</a>
								<button class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon" type="button">xxx</button>
								<ul class="wp-block-navigation__submenu-container wp-block-page-list-item">
									<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Child</a></li>
								</ul>
							</li>
						</ul>
						<div class="wp-block-buttons is-layout-flex">
							<div class="wp-block-button">
								<div class="wp-block-button__link wp-element-button">Button</div>
							</div>
							<div class="wp-block-button">
								<div class="wp-block-button__link wp-element-button">Button</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</nav>

Front

<nav class="items-justified-right is-responsive is-layout-flex is-horizontal is-content-justification-right wp-block-navigation">
	<button class="wp-block-navigation__responsive-container-open">
		...
	</button>
	<div class="wp-block-navigation__responsive-container">
		<div class="wp-block-navigation__responsive-close">
			<div class="wp-block-navigation__responsive-dialog">
				<button class="wp-block-navigation__responsive-container-close">
					...
				</button>
				<div class="wp-block-navigation__responsive-container-content">
					<ul class="wp-block-navigation__container is-responsive items-justified-right wp-block-navigation"> // todo
						<ul class="wp-block-page-list"> // todo
							<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Sample Page</a></li>
							<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Blog</a></li>
							<li class="wp-block-pages-list__item has-child wp-block-navigation-item open-on-hover-click">
								<a class="wp-block-pages-list__item__link wp-block-navigation-item__content">ホーム</a>
								<button class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle">...</button>
								<ul class="wp-block-navigation__submenu-container">
									<li class="wp-block-pages-list__item wp-block-navigation-item open-on-hover-click"><a class="wp-block-pages-list__item__link wp-block-navigation-item__content">Child</a></li>
								</ul>
							</li>
						</ul>
					</ul>
					<div class="wp-block-buttons is-layout-flex">
						<div class="wp-block-button">
							<a class="wp-block-button__link wp-element-button">Button</a>
						</div>
						<div class="wp-block-button">
							<a class="wp-block-button__link wp-element-button">Button</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</nav>
  • In the front, .is-responsive .items-justified-right .wp-block-navigation and other outermost classes are added to .wp-block-navigation__container, but but not in the editor
  • In the editor, .wp-block-navigation__container is a div, but in the front it is a ul.
  • In the editor, all inner blocks go in .wp-block-navigation__container, but not in the front if there are buttons (they go in .wp-block-navigation__responsive-container-content ).
  • There is no .has-block-overlay on the front page.
  • No .wp-block-page-list__submenu-icon on front
  • Submenu toggle buttons have .wp-block-navigation-item__content in the editor, but not in the front

Environment info

  • WordPress 6.5.2
  • Twenty Twenty-Four 1.1

It was the same whether Gutenberg 18.2.0 was installed or not.

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

@inc2734 inc2734 added the [Type] Bug An existing feature does not function as intended label Apr 27, 2024
@colorful-tones colorful-tones added the [Block] Navigation Affects the Navigation Block label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants