Skip to content

Rich Text editor appends an empty trailing paragraph on save #640

Description

@vincentgercke

Description

The Rich Text editor can append an empty paragraph when saving an edited value, even when the content visibly ends after the final line.

For example, the stored HTML changes from:

<p class="dw-paragraph-0">
    <a href="/about">About</a> | <a href="/contact">Contact</a>
</p>

to:

<p class="dw-paragraph-0">
    <a href="/about">About</a> | <a href="/contact">Contact</a>
</p>
<p></p>

The empty paragraph reappears after subsequent edits, requiring the editor to remove the blank line each time the value is saved.

Steps to reproduce

  1. Configure an item field to use Dynamicweb.Content.Items.Editors.RichTextEditor.
  2. Create or copy an item containing a single Rich Text paragraph with linked text.
  3. Edit the copied value and change only the text inside one of the links.
  4. Ensure there is no empty line after the content.
  5. Save the item.
  6. Reopen the item in the Visual Editor.
  7. Observe that an empty line has been appended.
  8. Inspect the rendered or stored HTML and observe the trailing <p></p>.

Expected behavior

The Rich Text editor should preserve the submitted content without appending an additional empty paragraph.

An empty paragraph should only be stored when the editor explicitly adds one.

Actual behavior

The editor appends an empty trailing paragraph when the value is saved.

Impact

The additional element can affect frontend layout and spacing. For example, styles targeting the last child may be applied to the generated empty paragraph instead of the final element
containing actual content.

It also creates an editorial issue because the empty line must be removed again after subsequent edits.

Environment

  • DynamicWeb 10.26.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions