Skip to content

Add the option to make the textarea required #1143

@metamoni

Description

@metamoni

<trix-editor> currently accepts autofocus and placeholder attributes, but not a required attribute. It would be useful to add this in, to get the basic validation mechanism that HTML provides.

At the moment we're relying on Active Record validation to prevent users from submitting a form without filling in this field. We also have to add aria-required="true" to notify screen reader users.

Steps to Reproduce
  1. Create a rich text area with required: true: <%= f.rich_text_area :about, class: "dm--input", required: true %>
  2. Try to submit the form without filling it out
  3. Notice that there's no HTML validation
Details
  • Trix Rails version: 7.1.3
  • Browser name and version: Chrome version 123.0.6312.59 (Official Build) (arm64)
  • Operating system: MacOS 14.4

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