WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 5 weeks ago

#48256 new defect (bug)

WP remove first <p> in <td>

Reported by: Sebafaim Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.2.3
Component: Editor Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

When I create table and add text inside it remove first <p> but let </p>
Example : <td><span class="" ></span></p>

Change History (4)

#1 follow-up: @mohsinrasool
4 months ago

@Sebafaim Please explain how can I reproduce it.

#2 in reply to: ↑ 1 @Sebafaim
4 months ago

Replying to mohsinrasool:

@Sebafaim Please explain how can I reproduce it.

I create a table with TinyMCE Advanced, and I add text inside the cell, and after I save.
I'm not doing anything else. Maybe wpautop ?

#3 @SergeyBiryukov
4 months ago

  • Component changed from General to Editor
  • Focuses coding-standards removed

#4 @alpipego
5 weeks ago

  • Keywords needs-patch added
  • Severity changed from minor to major

In wpautop a block element immediately followed by an inline(-block) element causes this issue. For me it was <div><img …>…</div> getting turned into <div><img …></p>…</div>.

The issue is that markup like this:

<div>
    <img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>
</div>

gets split into

<div><img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" />
<p>Here is some paragraph</p>
<div>

concatenated to

<p><div><img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" /></p>
<p><p>Here is some paragraph</p></p>
<p></div></p>

The opening <p> then gets removed for the first fragment above in https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php#L578 but the closing one stays.

I've changed the severity to major, since this leads to invalid HTML markup in the output.

Note: See TracTickets for help on using tickets.