Make WordPress Core

Opened 15 months ago

Last modified 7 days ago

#60993 new defect (bug)

Twenty Twenty-One: Preformatted block font size is smaller in the editor than on the front end

Reported by: viralsampat's profile viralsampat Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.6
Component: Bundled Theme Keywords: has-patch
Focuses: ui, css Cc:

Description

Hello,

I have reviewed the "Preformatted block" and found that its font-size is not same in editor & front-end sides. I have checked this issue for "Twenty Twenty" and "Twenty Twenty-One" themes. I think that it should be same on both editor & front-end sides.

Here, I have attached its screenshots.

Environment info:


WordPress version: WordPress 6.5.2 running,
Themes:

  • Twenty Twenty-One Version: 2.2
  • Twenty Twenty Version: 2.6

Browser: Google Chrome, Version 123.0.6312.107 (Official Build) (arm64)
Device: MacBook Air M1
OS: macOS 14.4.1 (23E224)
Gutenberg plugin: Version 18.1.0

Thanks,

Attachments (5)

twentyone_back_end.png (583.4 KB) - added by viralsampat 15 months ago.
Twenty-one Back-end
twentyone_front_end.png (460.3 KB) - added by viralsampat 15 months ago.
Twenty-one Front-end
twentytwenty_back_end.png (652.0 KB) - added by viralsampat 15 months ago.
TwentyTwenty Back-end
twentytwenty_front_end.png (591.8 KB) - added by viralsampat 15 months ago.
TwentyTwenty Front-end
60993.patch (1.9 KB) - added by nidhidhandhukiya 15 months ago.

Change History (17)

@viralsampat
15 months ago

Twenty-one Back-end

@viralsampat
15 months ago

Twenty-one Front-end

@viralsampat
15 months ago

TwentyTwenty Back-end

@viralsampat
15 months ago

TwentyTwenty Front-end

#1 @karmatosed
15 months ago

  • Keywords needs-patch added; dev-feedback removed

I am still seeing a difference in this. For example, in Twenty Twenty-One, there are 16px and 20px on the front.

#2 @sabernhardt
15 months ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 6.5 to 5.6

For the patch:

  • I agree with changing the size to 0.9em in Twenty Twenty's editor styles to match the front.
  • In Twenty Twenty-One, changing the value to 1em makes the block's font size equal to the front. Another possibility is removing that line entirely.

#3 @sabernhardt
15 months ago

  • Summary changed from Preformatted block font size issue. to Twenty Twenty-One: Preformatted block font size is smaller in the editor than on the front end

Twenty Twenty is also missing the border and padding, so that should be in a separate ticket. (#61845)

Last edited 7 days ago by sabernhardt (previous) (diff)

#4 @mayur8991
15 months ago

Patch Report - https://core.trac.wordpress.org/attachment/ticket/60993/60993.patch

Environment

WordPress - 6.5
OS - Windows
Browser - Firefox
Theme: Twenty Twenty-One Version: 2.2
PHP - 8.1.23

Before

After Patch

Result : Same font sizes displaying now for Preformatted block

#5 @karmatosed
13 months ago

  • Keywords needs-testing added

#6 @karmatosed
13 months ago

  • Keywords changes-requested added

I would like to see if we could refine this a bit more, as @sabernhardt recommended.

In Twenty Twenty-One, changing the value to 1em makes the block's font size equal to the front. Another possibility is removing that line entirely.

What does that result in? In my testing I think it could work and give us a much simpler solution.

#7 @karmatosed
12 months ago

  • Keywords needs-testing removed

#8 @karmatosed
12 months ago

@nidhidhandhukiya are you able to consider changes to this patch?

#9 @karmatosed
7 months ago

  • Keywords reporter-feedback added

This ticket was mentioned in PR #9166 on WordPress/wordpress-develop by @rishabhwp.


8 days ago
#10

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

This PR removes the font-size declaration from the pre.wp-block-preformatted selector in _editor.scss, as suggested in the ticket.
An alternative solution could be to update the font size to use var(--global--font-size-base) instead of the current var(--global--font-size-xs).

### Editor
https://github.com/user-attachments/assets/5a9c66b8-daf6-4777-8ab2-6941cc6911a1

### Frontend
https://github.com/user-attachments/assets/7b06d2ac-0c98-422a-914e-054a067b6aff

#11 @rishabhwp
7 days ago

  • Keywords changes-requested removed

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 138.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-One 2.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ The issue is reproducible in the Twenty Twenty-One theme.
  2. ❌ The issue is not reproducible in the Twenty Twenty theme. It appears to have been resolved in that theme.

Additional Notes

  • The issue, tracked in #61845, appears to have addressed the font size inconsistency between the editor and front-end for the preformatted block in the Twenty Twenty theme.
  • As the ticket had become stale, I have submitted a PR with the requested changes to address the issue in the Twenty Twenty-One theme.

Supplemental Artifacts

Twenty Twenty theme (Editor)

https://i.ibb.co/N6TBZHct/Screenshot-2025-07-02-at-2-55-30-PM.png

Twenty Twenty theme (Frontend)

https://i.ibb.co/CKC1QNhx/Screenshot-2025-07-02-at-2-55-46-PM.png

Twenty Twenty-One theme (Editor)

https://i.ibb.co/F4HztFZg/Screenshot-2025-07-02-at-3-10-23-PM.png

Twenty Twenty-One theme (Frontend)

https://i.ibb.co/pBpcVTG0/Screenshot-2025-07-02-at-3-10-45-PM.png

#12 @sabernhardt
7 days ago

  • Keywords reporter-feedback removed
Note: See TracTickets for help on using tickets.