Skip to content

Lexxy editor inserts <p><br></p> into params even when editor is empty #441

@tabosque

Description

@tabosque

I'm using Lexxy in a Ruby on Rails project, and I found that the editor sends unwanted HTML even when no content is entered.

Environment

  • Ruby: 3.4.7
  • Rails: 8.1.1
  • Lexxy: 0.1.20.beta

Setup

Post model has body in ActionText format.

has_rich_text :body

Problem

When I submit the form without typing anything in the Lexxy editor, the params already contain <p><br></p> instead of an empty string.
Here’s the captured params:

#<ActionController::Parameters {
  "authenticity_token" => "TOKEN",
  "post" => {"title" => "", "body" => "<p><br></p>"},
  "lexxy-code-language" => "plain",
  "commit" => "Create Post",
  "controller" => "posts",
  "action" => "create"
} permitted: false>

Expected behavior

If the editor is empty, I expect params[:post][:body] to be an empty string (""), not <p><br></p>.

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