Make WordPress Core

Opened 2 years ago

Last modified 3 weeks ago

#62289 new defect (bug)

Twenty Twenty: Search block looks different in editor and front end.

Reported by: nidhidhandhukiya Owned by:
Priority: normal Milestone: Future Release
Component: Bundled Theme Version: 6.6.2
Severity: normal Keywords: good-first-bug has-patch
Cc: Focuses:

Description

Steps to reproduce the issue:-

  1. Choose Search block.
  2. In editor and front side both you can able to see search label font is different and also input styling is different.

Attachments (2)

Screenshot 2024-10-23 at 11.50.42 PM.png​ (36.2 KB ) - added by nidhidhandhukiya 2 years ago.
Screenshot 2024-10-23 at 11.51.08 PM.png​ (25.8 KB ) - added by nidhidhandhukiya 2 years ago.

Download all attachments as: .zip

Change History (6)

#1 @desrosj
2 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone Awaiting Review → Future Release
  • Summary Twenty Twenty theme Search block looks different in editor and front end. → Twenty Twenty: Search block looks different in editor and front end.

Related: #59958.

Thanks @nidhidhandhukiya, I am able to reproduce this issue.

I do wonder if there are other default themes where this same issue is happening. It would be worthwhile to audit them all.

#2 @donetian
2 years ago

The problem is not present from Twenty Twenty-One onwards. This is due to the fact that the newer themes are using CSS variables instead of hardcoded font-family rules.

Here is Twenty Twenty-One for example:

https://i.imgur.com/DKQouFu.png

https://i.imgur.com/VDXnxdJ.png

On Twenty Twenty Gutenberg is using one font-family for the Search label, while another font-family is set on the Search label for the Preview page. This is due to the CSS rules for the .entry-content div container, under which the label is placed:

https://i.imgur.com/oLW5Lfd.png
https://i.imgur.com/DBWpkN2.png

One way for the problem to be resolved is for CSS variables to be set on the Twenty Twenty as well, but I do not know if it is worth the efforts to make such major overhaul changes to a theme which is already four-five years old.

The simpler change is to modify the .entry-content CSS rules in wp-content/themes/twentytwenty/style.css -> 11. Entry Content like how other CSS rules have been changed:

.entry-content .wp-block-file {
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}

Here is a hardcoded fix that works:

.entry-content .wp-block-search__label {
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}

https://i.imgur.com/mgWA0gn.png

The same goes for the input styling.

Version 0, edited 2 years ago by donetian (next)

This ticket was mentioned in ​PR #7877 on ​WordPress/wordpress-develop by ​donetian-petkov.


2 years ago
#3

  • Keywords has-patch added; needs-patch removed

I modified the .entry-content CSS rules in wp-content/themes/twentytwenty/style.css -> 11. Entry Content like how other CSS rules have been changed:

.entry-content .wp-block-search {
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}

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

This ticket was mentioned in ​PR #14996 on ​WordPress/wordpress-develop by ​CanoV2.


3 weeks ago
#4

Description

This PR addresses an additional font-size inconsistency in the Search block when using the Twenty Twenty theme.

The Search block label uses a 21px font size in the editor, but a 16px font size on the front end at the tested desktop viewport.

This change adds font-size: inherit to .entry-content .wp-block-search__label, allowing the label to inherit the font size from its parent container.

Testing

  • Activated the Twenty Twenty theme.
  • Added a Search block to a page.
  • Compared the label font size in the editor and on the front end.
  • Confirmed that the label uses 21px in both views after applying the change.

This complements the existing font-family fix proposed in PR #7877.

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT
Model(s): GPT-6
Used for: CSS investigation and code suggestions. The change was manually tested.

Note: See TracTickets for help on using tickets.