[WT-1677] Conditional block heading levels - #1794
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1794 +/- ##
==========================================
+ Coverage 90.08% 90.09% +0.01%
==========================================
Files 182 182
Lines 13219 13256 +37
==========================================
+ Hits 11908 11943 +35
- Misses 1311 1313 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The behavior change is well-scoped and backed by targeted tests; only a small docstring clarification was noted.
Pull request overview
This PR updates how free-form page templates compute heading levels so that leading blocks with conditional display rules can each render as h1 (ensuring the first heading a visitor actually sees is an h1), and adds a Wagtail admin warning to flag pages that start with multiple conditional heading blocks.
Changes:
- Add a
has_conditionsproperty to conditional-display values and use it from templates + hooks. - Update free-form templates to treat the “leading conditional run” of heading blocks as
h1s, while subsequent headings follow normal hierarchy (h2+). - Add a Wagtail
after_create_page/after_edit_pagewarning plus tests covering both the warning and the heading-level behavior (including excluding Notification headlines).
Note: This review was performed following the repository’s Copilot/AGENTS.md review guidance.
File summaries
| File | Description |
|---|---|
| springfield/cms/blocks.py | Adds ConditionalDisplayValue.has_conditions and wires it into ConditionalDisplayBlock via value_class. |
| springfield/cms/wagtail_hooks.py | Adds helpers to detect leading conditional heading blocks and warns editors via Django messages. |
| springfield/cms/templates/cms/free_form_page2026.html | Adjusts heading-level selection to keep leading conditional heading blocks at h1. |
| springfield/cms/templates/cms/smart_window_explainer_page.html | Mirrors the conditional-run heading-level logic for the explainer template. |
| springfield/cms/tests/test_pages.py | Adds tests verifying the editor warning hook behavior (including Notification preceding blocks). |
| springfield/cms/tests/test_blocks.py | Adds end-to-end HTML assertions ensuring heading hierarchy is correct across FreeForm/What’s New/Explainer pages. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| The run ends at the first heading block shown to everyone, since that block takes | ||
| the page's only h1 and every heading block after it drops to h2. |
One-line summary
Use
h1for all sequential conditional blocks at the top of a page so all users get served a page with the correct heading hierarchy.Significant changes and points to review
h1sheadline, but it isn't rendered as a heading element)Issue / Bugzilla link
https://mozilla-hub.atlassian.net/browse/WT-1677
Testing
Create free-form pages with different combinations of blocks with headings such that:
h1and the following ones withh2h1, followed byh2Unconditional:

Conditional:

Warning:
