Skip to content

Site Title: Fix logic for 'aria-current' attribute #68909

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

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

bschneidewind
Copy link
Contributor

@bschneidewind bschneidewind commented Jan 28, 2025

What?

This updates the core/site-title block and the aria-current attribute. This should only be applied to the front page and prevents the aria-current being applied if a user has a separate front page from the posts page. (the posts page should not have an aria-current attribute applied to site title in these instances)

Why?

Resolves bug where a separate posts page has the site-title attribute applied to the site-title (should only be applied to the front page)

How?

Testing Instructions

  1. Under settings->reading select a posts page and a homepage.
  2. Visit the posts page on the front end and inspect the site title, you'll see an aria-current attribute applied.

Trac ticket: https://core.trac.wordpress.org/ticket/62874

Copy link

github-actions bot commented Jan 28, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @bjschneidewind@santanderconsumerusa.com.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: bjschneidewind@santanderconsumerusa.com.

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: sabernhardt <sabernhardt@git.wordpress.org>
Co-authored-by: bschneidewind <bschneidewind@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @bschneidewind! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jan 28, 2025
@hbhalodia
Copy link
Contributor

Hi @bschneidewind, Can you please add the core trac ticket here? or create an issue on this repo to reference this PR?

Thank You,

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Site Title Affects the Site Title Block labels Jan 28, 2025
@hbhalodia hbhalodia requested a review from joedolson January 28, 2025 06:55
@sabernhardt
Copy link
Contributor

The Home Link block has a different conditional statement:

$aria_current = '';
if ( is_front_page() ) {
$aria_current = ' aria-current="page"';
} elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
// Edge case where the Reading settings has a posts page set but not a static homepage.
$aria_current = ' aria-current="page"';
}

And neither block matches the condition in get_custom_logo():
$aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : '';

@bschneidewind
Copy link
Contributor Author

Thank you @sabernhardt - helped ID another edge case and reworked this code a bit!

@Mamaduka Mamaduka changed the title Remove the aria-current attribute from being applied to the site titl… Site Title: Fix logic for aria-current attribute Jan 29, 2025
@Mamaduka Mamaduka changed the title Site Title: Fix logic for aria-current attribute Site Title: Fix logic for 'aria-current' attribute Jan 29, 2025
@carolinan
Copy link
Contributor

Test results

Your homepage displays Your latest posts

Home:
✅ The site title has aria-current="page".
Paged result of the blog post archive:
✅ The site title does not have aria-current="page".

Your homepage displays A static page

Homepage is selected in the option. Posts page is selected in the option.
Home:
✅ The site title has aria-current="page".
Posts page:
✅ The site title does not have aria-current="page".

Homepage is selected in the option. Posts page is not selected.
Home:
✅ The site title has aria-current="page".

Homepage is not selected in the option. Posts page is selected.
Home:
✅ The site title has aria-current="page".
Paged result of the blog post archive:
✅ The site title does not have aria-current="page".

@carolinan
Copy link
Contributor

I am moving this to the 6.8 board because the original trac ticket is on the 6.8 milestone, labeled as an accessibility bug.

@github-project-automation github-project-automation bot moved this to 🔎 Needs Review in WordPress 6.8 Editor Tasks Feb 28, 2025
@carolinan carolinan added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Feb 28, 2025
@Mamaduka Mamaduka added Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta props-bot Adding this label triggers the Props Bot workflow for a PR. labels Mar 5, 2025
@github-actions github-actions bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Mar 5, 2025
@Mamaduka Mamaduka merged commit 5e9bb89 into WordPress:trunk Mar 5, 2025
72 checks passed
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 6.8 Editor Tasks Mar 5, 2025
@github-actions github-actions bot added this to the Gutenberg 20.5 milestone Mar 5, 2025
Mamaduka pushed a commit that referenced this pull request Mar 5, 2025
Unlinked contributors: bjschneidewind@santanderconsumerusa.com.

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: sabernhardt <sabernhardt@git.wordpress.org>
Co-authored-by: bschneidewind <bschneidewind@git.wordpress.org>
@Mamaduka
Copy link
Member

Mamaduka commented Mar 5, 2025

I just cherry-picked this PR to the wp/6.8 branch to get it included in the next release: 9f8d16d.

@Mamaduka Mamaduka added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Mar 5, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Unlinked contributors: bjschneidewind@santanderconsumerusa.com.

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: sabernhardt <sabernhardt@git.wordpress.org>
Co-authored-by: bschneidewind <bschneidewind@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Site Title Affects the Site Title Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging this pull request may close these issues.

7 participants