You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
It looks like we'll get closer to the rendered markup by making div.wp-block-navigation-link__content into an <a> element. Which works, except when I try to commit, I get an a11y error:
431:5 error The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
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.
Activity
georgeh commentedon Feb 26, 2021
👀
jasmussen commentedon Mar 8, 2021
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.
georgeh commentedon Mar 8, 2021
<a>works well enough as theRichTexttag name, but theRichTextis actually inside a<div>that should be changed to<a>Here's the current rendered markup:
Here's the current editor markup: (the difference is at the 4th line)
It looks like we'll get closer to the rendered markup by making
div.wp-block-navigation-link__contentinto an<a>element. Which works, except when I try to commit, I get an a11y error: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.
jasmussen commentedon Mar 9, 2021
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.
Navigation Link: Match Editor Markup to Rendered
Navigation Link: Match Editor Markup to Rendered (#29935)
ntsekouras commentedon Mar 18, 2021
Sorry for missing the ping 😢 - Too many GH notifications. I see the issue was resolved now..
jasmussen commentedon Mar 18, 2021
No worries, we worked it out 🎉