Skip to content

Site Title: Prevent saving and rendering a value made of only spaces #69628

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

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Mar 19, 2025

What?

Closes #60467

Prevents the Site Title block from saving and rendering values made only of whitespace characters

Why?

The Site Title block was inconsistent with the classic admin behavior - it would allow saving site titles with only spaces, which created empty links on the front end. Empty links are problematic for SEO and accessibility.
This inconsistency created a situation where:

  • Classic admin wouldn't save site titles with only spaces
  • The Site Title block would save them
  • This would render an empty link on the frontend

How?

The solution addresses the issue in two places:

  • In the editor component (edit.js): Trim whitespace from the title before saving it
  • In the PHP render callback (index.php): Skip rendering if the site title consists only of whitespace

Testing Instructions

  • Use a theme that has the Site Title block on one of its templates (e.g., Twenty Twenty-Four > Blog Home template)
  • Go to the Site Editor and select the Site Title block
  • Clear the title and enter only spaces
  • Save the template
  • Check the frontend - verify no empty link is rendered
  • Check the classic admin (Settings > General) - verify the site title field is empty
  • Try to enter only spaces in the classic admin site title field and save
  • Verify the site title remains empty in both the classic admin and the Site Editor

Screencast

Before

Screen.Recording.2025-03-20.at.16.59.34.mp4

After

Screen.Recording.2025-03-20.at.17.08.16.mov

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Site Title Affects the Site Title Block labels Mar 19, 2025
@himanshupathak95 himanshupathak95 marked this pull request as ready for review March 20, 2025 11:22
Copy link

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.

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

Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: afercia <afercia@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
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mamaduka Mamaduka merged commit 7129676 into WordPress:trunk Mar 20, 2025
64 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.6 milestone Mar 20, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…ordPress#69628)

Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Site Title Affects the Site Title Block [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
None yet
Development

Successfully merging this pull request may close these issues.

Site Title: prevent from saving and rendering a value made of only spaces
2 participants