Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to make the textarea required #1143

Closed
metamoni opened this issue Mar 25, 2024 · 2 comments
Closed

Add the option to make the textarea required #1143

metamoni opened this issue Mar 25, 2024 · 2 comments

Comments

@metamoni
Copy link

<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
@seanpdoyle
Copy link
Contributor

I consider this issue to overlap with #1023 and #1128.

While #1128 does not add support for the [required] attribute, it does set the foundation for follow ups to integrate with ElementInternals.validity.

@afcapel
Copy link
Contributor

afcapel commented Mar 25, 2024

I agree with @seanpdoyle, the way to go is through ElementInternals so the custom element can take part in the form validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants