Skip to content

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

Merged
Mamaduka merged 2 commits into
WordPress:trunkfrom
bschneidewind:patch-1
Mar 5, 2025
Merged

Site Title: Fix logic for 'aria-current' attribute#68909
Mamaduka merged 2 commits into
WordPress:trunkfrom
bschneidewind:patch-1

Conversation

@bschneidewind
Copy link
Copy Markdown
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

@github-actions
Copy link
Copy Markdown

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: @[email protected].

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: [email protected].

Co-authored-by: carolinan <[email protected]>
Co-authored-by: joedolson <[email protected]>
Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: sabernhardt <[email protected]>
Co-authored-by: bschneidewind <[email protected]>

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

@github-actions
Copy link
Copy Markdown

👋 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 props-bot Manually triggers Props Bot to ensure the list of props is up to date. labels Mar 5, 2025
@github-actions github-actions Bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Mar 5, 2025
@Mamaduka Mamaduka merged commit 5e9bb89 into WordPress:trunk Mar 5, 2025
@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: [email protected].

Co-authored-by: carolinan <[email protected]>
Co-authored-by: joedolson <[email protected]>
Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: sabernhardt <[email protected]>
Co-authored-by: bschneidewind <[email protected]>
@Mamaduka
Copy link
Copy Markdown
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 labels Mar 5, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Unlinked contributors: [email protected].

Co-authored-by: carolinan <[email protected]>
Co-authored-by: joedolson <[email protected]>
Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: sabernhardt <[email protected]>
Co-authored-by: bschneidewind <[email protected]>
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

No open projects

Development

Successfully merging this pull request may close these issues.

7 participants