CKEditor list adds unwanted P tag on restricted HTML

Created on 22 February 2021, over 3 years ago
Updated 1 February 2023, almost 2 years ago

Problem/Motivation

When adding a list CKEditor with Restricted HTML mode a <p> tag gets added after the text if the second item is indented.

Steps to reproduce

  1. Enable CKEditor for the Restricted HTML mode
  2. Check the setting, Convert line breaks into HTML (i.e. <br> and <p>) found here /admin/config/content/formats/manage/restricted_html?destination=/admin/config/content/formats
  3. Add some new content using the Restricted HTML mode and add an unordered list. Indent the second item.
  4. Add another unordered list bellow and just indent the third item (first two normal, then the third one indented).
  5. Save and view the result. Inspect the list and check that there is an extra <p> tag added to the <li> element right after the text. This <p> tag has standard margins from the browser that creates a big space to the "parent" list item.
  6. Compare to the other unordered list. There should not be an extra space on that list:

Expected behavior is that no extra <p> tags gets added to list items and that it should be consistent no matter which list items are indented.

This only happens with the Restricted HTML mode. I have tested on several Drupal installations and been able to reproduce every time. The problem goes away if the Convert line breaks into HTML (i.e. <br> and <p>) is unchecked but I expect that this isn't the expected behavior since it only affects list where the second list item is indented. I does not happen with the ordered lists.

Proposed resolution

None. It is fixable with CSS but that would be a bad workaround since it might be desirable with margins if paragraph tags are used inside unordered lists.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

πŸ’¬ Support request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡ͺSweden Kaffia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024