Make WordPress Core

Opened 4 months ago

Last modified 2 weeks ago

#65433 new enhancement

Twenty Nineteen: replace whitespace character for heading decoration

Reported by: karunyachavan84 Owned by:
Priority: normal Milestone: 7.2
Component: Bundled Theme Version: 5.0
Severity: minor Keywords: has-patch
Cc: Focuses: ui, css

Description

In the Twenty Nineteen theme, an empty Heading block can display an unexpected hyphen character in the block editor when underline text decoration is active. The issue can be observed in the image below.

https://drive.google.com/file/d/16EiTRZOeJ8lCgiu-myI78fYNJyptQ4LJ/view

Steps to Reproduce

  1. Activate the Twenty Nineteen theme.
  2. Open the WordPress editor.
  3. Insert a Heading block.
  4. Leave the Heading block empty.
  5. Apply underline/strikethrough text decoration (or use styling that enables underlined headings).
  6. Observe the rendering of the empty Heading block in the editor.

Expected Result

The heading decoration line should be displayed correctly, and no additional characters should appear when the Heading block is empty.

Actual Result

A visible hyphen-like character appears in the empty Heading block.

Attachments (2)

T19-headings-underlined-editor.png​ (47.5 KB ) - added by sabernhardt 4 months ago.
headings with underline setting, in editor
T19-headings-underlined-front.png​ (37.9 KB ) - added by sabernhardt 4 months ago.
headings with underline setting, front

Download all attachments as: .zip

Change History (6)

This ticket was mentioned in ​PR #12121 on ​WordPress/wordpress-develop by ​@karunyachavan84.


4 months ago
#1

  • Keywords has-patch added

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

When a user inserts an empty heading block in the editor and applies an "Underline" or "Strikethrough" text decoration, the browser attempts to underline the pseudo-element's whitespace character. This interaction causes a stray, visible hyphen-like artifact to render inside the editor above the empty block as

https://github.com/user-attachments/assets/b6b7069d-c88e-4659-a48f-f00463ec1cb0

---

https://github.com/user-attachments/assets/ce322734-4753-42c3-85c7-5e9449dfe48d

## What this Changes

  • This PR updates the post-section-dash mixin in sass/mixins/_mixins-master.scss to use an empty string (content: "";) instead of content: "\020".
  • By removing the whitespace character, the pseudo-element no longer contains an actual text node.
  • Since the element has explicit display: block, width, and height properties, the decorative dash continues to render identically on the frontend and backend.
  • However, because there is no text content, the browser can no longer underline a whitespace character, completely resolving the visual bug in the editor without requiring any editor-specific CSS overrides.

https://github.com/user-attachments/assets/1862b061-d8a9-47a9-a331-14a0b64b3714

## Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): GPT-4o
Used for: To verify optimality and efficiency of the patch.

---

#2 @sabernhardt
4 months ago

  • Component Themes → Bundled Theme
  • Keywords close added
  • Severity normal → minor
  • Summary Twenty Nineteen: Empty Heading block displays stray hyphen in editor when underline decoration is enabled. → Twenty Nineteen: replace whitespace character for heading decoration
  • Type defect (bug) → enhancement
  • Version trunk → 5.0

Headings should not be empty.

Additionally, the underline style can confuse people when the text is not linked.
​https://equalizedigital.com/accessibility-checker/underlined-text/

The extra line is only visible in the editor because the heading element's style attribute includes white-space: pre-wrap there, and the pseudo-element inherits that rule. Twenty Nineteen's whitespace character pseudo-element could discourage people from using the text decoration setting on the full heading block, without needing to install a plugin such as ​Accessibility Checker (for this situation).

That said, content: "" seems to work just as well as content: "\020" for H1 and H2 headings.

Last edited 4 months ago by sabernhardt (previous) (diff)

@sabernhardt
4 months ago

headings with underline setting, in editor

@sabernhardt
4 months ago

headings with underline setting, front

#3 @tusharaddweb
4 months ago

Tested on WordPress 5.0 with Twenty Nineteen theme activated.

Reproduced the issue a hyphen-like character appears in an empty Heading block when underline or strikethrough text decoration is applied.

After applying the patch the stray character no longer appears. The decorative dash continues to render correctly on both the frontend and in the editor. Patch works as expected.

#4 @karmatosed
2 weeks ago

  • Keywords close removed
  • Milestone Awaiting Review → 7.2

I 'think' we don't want close on this as we have a patch, so moving this to a candidate for 7.2 just incase. I realise there is a comment about headings being empty but there also is a patch that does provide some solution.

Note: See TracTickets for help on using tickets.