Linking an image creates an empty paragraph tag in CKEditor

Created on 5 May 2017, over 7 years ago
Updated 31 January 2023, almost 2 years ago

In #2510380: Images cannot be linked in CKEditor β†’ , we added the ability to link images even when using the CKEditor "widget" for image handling. There seems to be some kind of minor bug in the implementation.

Steps to reproduce:

- Create a piece of content.
- Add a single line of text and insert a new line. There is now one paragraph in the source code.
- Insert an image through the image button. Save the dialog.
- Click on the image in the editor.
- Click the link button. Add a URL and save the dialog.

Note at this point, the tag breadcrumb in CKEditor says body > p > p > img. Inspecting the source with your browser indicates that two <p> tags are nested incorrectly. If you click the "Source" button in CKEditor, the paragraph tags become unnested and you end up with code like this:

<p>First paragraph</p>

<p>&nbsp;</p>

<p><img src="..." /></p>

Note this problem does not exist if you have aligned the imaged (center or right). It does still exist if you add a caption.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States quicksketch

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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