redactor icon indicating copy to clipboard operation
redactor copied to clipboard

Redactor frequently adds line breaks at the end of block elements

Open nicbou opened this issue 3 years ago • 3 comments

Description

If I take any article I've edited with Redactor, I see <br> tags at the very end of <li> and <p> tags, just before the closing tag. This happens in Firefox and Chrome. It happens on all versions of Craft and Redactor I have used in the last 4 years.

This causes various small issues when editing text.

Steps to reproduce

  1. Edit text for a while
  2. Look at the source

nicbou avatar Feb 08 '22 15:02 nicbou

One reliable way to reproduce this is to have two paragraphs, then positioning the caret at the very beginning of the second paragraph and hitting enter. For some reason, this generates <p><br></p>. Then, when hitting backspace, it deletes the paragraph, but moves the <br> tag to the very end of the previous paragraph.

I can reproduce this on Imperavi's website.

I'm sorry to say this is another Redactor core bug and is a bit out of our hands..

andris-sevcenko avatar Feb 09 '22 07:02 andris-sevcenko

This is still a serious annoyance for me. Is there perhaps a way to filter those out through Craft?

nicbou avatar Jul 27 '22 14:07 nicbou

I currently fix this with a template filter:

{{
  body|replace({
    '<br></p>': '</p>',
    '<br></li>': '</li>',
  })
}}

nicbou avatar Dec 01 '22 11:12 nicbou