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

Feature request: add validation that rich text fields don’t contain empty headings #6526

Closed
thibaudcolas opened this issue Nov 6, 2020 · 3 comments · Fixed by #8805
Closed

Comments

@thibaudcolas
Copy link
Member

Is your proposal related to a problem?

Prompted by a discussion on #6272 / #6090. It’s problematic for screen reader users if there are empty headings on pages. There is no validation for this in rich text fields.

Describe the solution you'd like

In StreamField it’s very easy for developers to make sure heading blocks are required (using CharBlock, required is the default). We should have something equivalent for rich text.

The default should be for all of h1, h2, h3, h4, h5, h6 to require having text in the block if present. It would be nice if this was configurable for people who would want paragraphs (#4431) or list items to be required, but this doesn’t have as clear of an impact accessibility-wise so shouldn’t be the default.

Describe alternatives you've considered

This could be implemented per-project, but really since Wagtail provides rich text out of the box, this type of validation should also be there out of the box. There are no use cases we would want to support for empty headings.

Additional context

I think this is a stretch but it would be nice if this was:

  • Extensible to support other types of rich text validation in the future (for example, validating that link text isn’t "click here")
  • Configurable by implementers of Wagtail (for example, to make their own custom blocks required, or to restrict link text further)
@thibaudcolas
Copy link
Member Author

thibaudcolas commented Nov 27, 2020

Discussing this with @helenb today, and in the accessibility team’s meeting last week, a simpler implementation might just be to strip those heading levels from rich text on save.

Personally I’m more inclined to use validation so end users are more aware of the issue, but happy with the more radical approach as well if there is agreement it’s a good fit for Wagtail (and whether it should be opt-out, opt-in, configurable in some way). With this approach, this is partly related to #4223.

@Scotchester
Copy link
Contributor

Thinking about this sort of validation today, as we've seen some unfortunate behaviors recently that we'd love to prevent:

  1. Making sure heading levels are not skipped (when available as features in a Draftail field)
  2. Making sure that entire paragraphs in a rich text field/block are not bolded/italicized/capitalized as a stand-in for headings (when headings are not available in Draftail and we are trying to force them to be in their own block)

@thibaudcolas
Copy link
Member Author

As of #8805, we’re making empty heading blocks much more visually prominent. This strikes me as an appropriate solution to this issue, even if there is no actual validation, so I’ll close this now.

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

Successfully merging a pull request may close this issue.

3 participants