-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation Block: Try contenteditable anchor (a
) markup
#28575
Comments
👀 |
This is possible, as the Query Pagination uses it. Try to install a block based theme, https://github.com/WordPress/theme-experiments. Then visit the Site Editor, and insert a Pagination block. You'll note it uses an editable a tag. |
Here's the current rendered markup: <nav class="wp-block-navigation">
<ul class="wp-block-navigation__container">
<li class="wp-block-navigation-link">
<a class="wp-block-navigation-link__content" href="http://example.com">
<span class="wp-block-navigation-link__label">example.com</span>
</a>
</li>
</ul>
</nav> Here's the current editor markup: (the difference is at the 4th line) <nav class="… wp-block-navigation" …>
<ul class="wp-block-navigation__container …">
<li class="… wp-block-navigation-link" …>
<div class="wp-block-navigation-link__content">
<div … class="block-editor-rich-text__editable …" contenteditable="true">example.com</div>
</div>
…
</li>
…
</ul>
</nav> It looks like we'll get closer to the rendered markup by making
I suspect that's how we wound up with this markup to start with. I think that this might be a special case where we aren't trying to create a link-like button but rather non-interactive link-like text. If so, I can tell the linter to ignore this rule here, but would appreciate a double-check from someone with more a11y experience. |
CC: @ntsekouras can you take a look here? I believe you worked on the Query Pagination block which uses the a element. In this case it seems fineto provide a linter exception to the rule, as you are building the page, not writing markup meant to be navigated. |
Change <div> to <a> for Navigation Link Block in the Editor Closes #28575
Sorry for missing the ping 😢 - Too many GH notifications. I see the issue was resolved now.. |
No worries, we worked it out 🎉 |
Extracted from #28265 (comment).
The closer the editor markup of a block matches that of the frontend, the easier it is to write CSS that just works. For the navigation block, the markup of a basic menu in the editor is this (lightly trimmed for clarity):
Compare with the frontend:
These are faaairly close on classes and markup, but the primary differentiator making styles differ is this one:
<div class="wp-block-navigation-link__content">
If that
div
could become ana
instead, in the editor, the CSS to style both would be slightly simpler.From a very superficial and maybe faulty investigation, it seems like it should be possible to use a contenteditable anchor. So it seems worth exploring.
The text was updated successfully, but these errors were encountered: