Make WordPress Core

Opened 7 weeks ago

Closed 8 days ago

#62243 closed defect (bug) (fixed)

Twenty Twenty: Latest post block there is no space between post-author/post-date and post content on the front-end.

Reported by: viralsampat's profile viralsampat Owned by: karmatosed's profile karmatosed
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Bundled Theme Keywords: has-patch commit
Focuses: css Cc:

Description

Hello Team,

I have checked "Latest Post" block and found that when we add post-author/post-date there is no space between post-author/post-date and post content on the front-end, But on the admin editor side it looks good, There is some space between post-author/post-date and post content.

For better understanding, Here I have attached its screenshots:

Thanks,

Attachments (7)

latest-post-block-editor.png (387.4 KB) - added by viralsampat 7 weeks ago.
Back-end
latest-post-block-editor.2.png (387.4 KB) - added by viralsampat 7 weeks ago.
Back-end:
latest-post-block-front-end.png (320.2 KB) - added by viralsampat 7 weeks ago.
Front-end:
62243.patch (555 bytes) - added by viralsampat 7 weeks ago.
I have checked above mentioned issue and I have resolved it and added patch. Also, I have attached screenshot after resolved this issue.
after-resolved-latest-post-block-editor.png (386.3 KB) - added by viralsampat 7 weeks ago.
After resolved issue Back-end:
after-resolved-latest-post-block-front-end.png (288.7 KB) - added by viralsampat 7 weeks ago.
After resolved issue front-end:
62243.1.patch (2.0 KB) - added by sabernhardt 2 weeks ago.
adds 1em top margin to a paragraph if it is the first element in the post content, within a Latest Posts block

Download all attachments as: .zip

Change History (14)

@viralsampat
7 weeks ago

I have checked above mentioned issue and I have resolved it and added patch. Also, I have attached screenshot after resolved this issue.

@viralsampat
7 weeks ago

After resolved issue Back-end:

@viralsampat
7 weeks ago

After resolved issue front-end:

#1 @sainathpoojary
4 weeks ago

Hey @viralsampat,

Thanks for raising this issue! I couldn’t reproduce it on my end.

Here’s what I tested:

  • Twenty Twenty theme on WordPress versions 6.7 to 6.4
  • Twenty Twenty theme on Local by Flywheel on WordPress 6.6

After checking the style.css file from core/latest-posts, I found this rule:

.wp-block-latest-posts__post-excerpt {
margin-top: 0.5em;
margin-bottom: 1em;
}

This CSS rule adds a top margin, which appears to be adding the gap.

You can view the relevant code here:

https://github.com/WordPress/gutenberg/blob/249c0cf495ed89df95e039572974bc948fa89731/packages/block-library/src/latest-posts/style.scss#L60C1-L63C2

Could you please provide more details or any additional steps needed to replicate the issue?

Thanks!

#2 @desrosj
2 weeks ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Summary changed from Twenty Twenty Theme: Latest post block there is no space between post-author/post-date and post content on the front-end. to Twenty Twenty: Latest post block there is no space between post-author/post-date and post content on the front-end.

@viralsampat are you still able to reproduce this issue?

@sabernhardt
2 weeks ago

adds 1em top margin to a paragraph if it is the first element in the post content, within a Latest Posts block

#3 @sabernhardt
2 weeks ago

  • Keywords has-patch added; needs-patch reporter-feedback removed
  • Severity changed from normal to minor

The lack of space can occur when

  1. the Latest Posts block is set to show "Full post" and
  2. the first element/block in the post is a paragraph.

The excerpt option has a small margin from block styles (GB15722), but #47340 added a margin for the full post option in Twenty Nineteen and PR 153 set the same top margin for both options in Twenty Twenty-One.

In Twenty Twenty, paragraphs have zero top margin. In contrast, a heading as the first block can have a top margin of 3.5rem or more, and the Image block has a 4rem margin.

Patch notes:

  • If the selector targets the paragraph element, it needs to apply only when that paragraph is at the beginning of the post. 62243.1.patch uses .wp-block-latest-posts__post-full-content > p:first-child.
  • Targeting the .wp-block-latest-posts__post-full-content div is another option. It would give a minimum margin above the post content, and I did not notice that rule increasing the space when the first inner block has its own margin.
  • If this were the newest theme, I would suggest giving the :first-child a consistent margin regardless of the element. However, five years later, I would prefer to keep any changes minimal.
  • The .entry-content class (62243.patch) would apply styles only within page/post content, and the Latest Posts block is intended for the Widgets area(s).

#4 @abcd95
11 days ago

  • Keywords needs-testing removed

Test Report

Description

This report validates that the suggested patch works as expected.

Patch tested: 62243.1.patch

Environment

  • WordPress: 6.8-alpha-59274-src
  • PHP: 8.2.25
  • Server: nginx/1.27.2
  • Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.25)
  • Browser: Chrome 131.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty 2.8

Actual Results

✅ Issue resolved with the patch.

Supplemental Artifacts

Back-end: https://postimg.cc/xJn7Vv85
Front-end: https://postimg.cc/QFn13hMy

#5 @karmatosed
8 days ago

I am going to move this patch to testing; thanks.

#6 @karmatosed
8 days ago

  • Keywords commit added

In testing, I can confirm this is still an issue, but the patch uploaded by @sabernhardt resolves it. I am, therefore, going to move this to commit now. Thank you, everyone.

#7 @karmatosed
8 days ago

  • Owner set to karmatosed
  • Resolution set to fixed
  • Status changed from new to closed

In 59470:

Twenty-Twenty: Fixes space between post content on front.

The post author and post date did not have space between them and the post content. This brings in 1em of top margin. Of note is that this only is if the first element is a paragraph that the issue was caused.

Props abcd95, sabernhardt, desrosj, sainathpoojary, viralsampat.
Fixes #62243.

Note: See TracTickets for help on using tickets.