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
Comments
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. |
Thinking about this sort of validation today, as we've seen some unfortunate behaviors recently that we'd love to prevent:
|
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. |
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:
The text was updated successfully, but these errors were encountered: