WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 6 weeks ago

#29643 new defect (bug)

Ordered List Problem When Switiching between Visual Editor and HTML editor

Reported by: pavankumarp Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Editor Keywords:
Focuses: Cc:

Description

  1. I create an ordered list in the Visual Editor.
  1. I switch to the HTML editor so I can add a paragraph of text (or an image) within the ordered list, but NOT inside a list tag.
  1. I return to the Visual Editor and notice something doesn't look right.
  1. I go back to the HTML editor and see that my ordered list is now all messed up. Extra ordered list tags have been added that I don't want.

Here's the code from the HTML editor BEFORE I switched back to the Visual Editor:

<ol>

<li>Ordered list item 1</li>

Block of text inserted into list but not inside an li tag.

<li>Ordered list item 2</li>
<li>Ordered list item 3</li>
<li>Ordered list item 4</li>

</ol>

Here's the code after switching to the Visual Editor and then back to the HTML editor:

<ol>
<ol>

<li>Ordered list item 1</li>

</ol>
</ol>
Block of text inserted into list but not inside an li tag.
<ol>

<li>Ordered list item 2</li>
<li>Ordered list item 3</li>
<li>Ordered list item 4</li>

</ol>

Change History (6)

#1 follow-up: @Bonesnap
5 years ago

Someone correct me if I am wrong, but I believe all content within an <ol> element (and <ul> for that matter) must be within <li></li> tags. The editor is probably recognizing this and trying to correct it.

#2 in reply to: ↑ 1 @SergeyBiryukov
5 years ago

Replying to Bonesnap:

Someone correct me if I am wrong, but I believe all content within an <ol> element (and <ul> for that matter) must be within <li></li> tags.

That's right.

#3 @iseulde
5 years ago

I think the reporter is trying to say that the correction is invalid as well (an ol tag inside an ol tag).

#4 @pavankumarp
5 years ago

Yeah avryl, After the corrections. Every point appears with number 1 because <ol> tags are being closed for every point.

#5 @Bonesnap
5 years ago

I don't think it should be the text editor's responsibility to fix malformed HTML - especially if we know the HTML we're giving it is incorrect. Seems to me the easiest solution to this problem is to make sure you put <li></li> tags around any content you want to put in the list, no?

#6 @marcochiesi
5 years ago

I noticed the same problem when using comments inside lists.
Example:

<ol>
<li>Ordered list item 1</li>
<li>Ordered list item 2</li>
<li>Ordered list item 3</li>
<!-- This is a comment -->
</ol>

becomes

<ol>
<ol>
	<li>Ordered list item 1</li>
	<li>Ordered list item 2</li>
	<li>Ordered list item 3</li>
</ol>
</ol>
<!-- This is a comment -->

The comment gets moved and the ol/ul tag is duplicated. So this is definitely a bug.

Note: See TracTickets for help on using tickets.