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

Insert post navigation links as two links inside a <nav> element #55157

Open
carolinan opened this issue Oct 9, 2023 · 0 comments
Open

Insert post navigation links as two links inside a <nav> element #55157

carolinan opened this issue Oct 9, 2023 · 0 comments
Assignees
Labels
[Block] Post Navigation Link Affects the Post Navigation Link Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.

Comments

@carolinan
Copy link
Contributor

carolinan commented Oct 9, 2023

What problem does this address?

The post navigation link block: AKA the next and previous post links for single posts, can be difficult for users to insert correctly, because you need to add two copies of the block and then change one of the variations.

For the next and previous navigation to be as accessible as possible, both blocks needs to be placed inside a <nav> element.
While the user can place the blocks inside a group, the group does not have an interface for changing the element from a <div> to a <nav>. It can only be done by changing the code in the code editor. This limitation was created on purpose because you need advanced knowledge of when to use the <nav> to not cause unintended accessibility problems.

You can compare this with inserting the query pagination block. This block already uses a nav, and the three inner blocks are placed together: Next page, the paginated links, and previous page.

What is your proposed solution?

Instead of the inserter adding the individual next and previous links, it should prioritise a pattern where both blocks are placed in a way that ensures accessible markup.

In the example pattern below, note that besides the <nav> element, a unique, identifying aria label is added to the group:

<?php
/**
 * Title: Post navigation
 * slug: twentytwentyfour/post-navigation
 * inserter: no
 */
?>

<!-- wp:group {"tagName":"nav","ariaLabel":"<?php esc_attr_e( 'Posts', 'twentytwentyfour' ); ?>","style":{"spacing":{"padding":{"bottom":"0vh"}}},"layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->
<nav class="wp-block-group" style="padding-bottom:0vh" aria-label="<?php esc_attr_e( 'Posts', 'twentytwentyfour' ); ?>">
<!-- wp:post-navigation-link {"type":"previous","label":"<?php echo esc_html_x( 'Previous: ', 'Label before the title of the previous post. There is a space after the colon.', 'twentytwentyfour' ); ?>","showTitle":true,"linkLabel":true,"arrow":"arrow"} /-->
<!-- wp:post-navigation-link {"label":"<?php echo esc_html_x( 'Next: ', 'Label before the title of the next post. There is a space after the colon.', 'twentytwentyfour' ); ?>","showTitle":true,"linkLabel":true,"arrow":"arrow"} /-->
</nav>
<!-- /wp:group -->
@carolinan carolinan added the [Block] Post Navigation Link Affects the Post Navigation Link Block label Oct 9, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Oct 9, 2023
@carolinan carolinan self-assigned this Jan 9, 2024
@carolinan carolinan added the New Block Suggestion for a new block label Jan 9, 2024
@carolinan carolinan added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Navigation Link Affects the Post Navigation Link Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants