1

We use a Visualforce page to automatically fill a rich text field with some generated content. After that, the user is allowed to edit the content before it's displayed on a website. After our migration to Lightning, the behavior of the rich text fields seems to have changed. The rich text field still accepts the formatting as it used to when filled through Apex code. Unfortunately, when the user edits the field the following happens:

  • Break tags outside paragraph tags have paragraph tags added around them.
  • Break tags inside paragraph tags are converted to new paragraphs.
  • Div tags are converted to paragraph tags.
  • All id and class attributes are removed.

Is there a way we can use break tags in a Lightning rich text field? If not, I'd be interested in a workaround.

1

Everything I've tried so far indicates this isn't possible. Every <br> tag upon saving immediately becomes <p><br></p>. This happens before the before update triggers are run, which limits my possibilities to deal with it. For now I've opted to use css on the website to remove the top and bottom margin from my <p> tags. This allows me to manually create a distinction between paragraphs and line breaks but it removes some of the design flexibility that should be there.

Update: Salesforce support got back to me and this is 'working as designed'. Their documentation will be updated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.