Skip to content

Commit

Permalink
fix(templates): allow custom media-item--heading tag
Browse files Browse the repository at this point in the history
previously h3 was hardcoded as the heading tag for media items

this caused a bug in enrollment index, where heading levels skip
from h1 (the page title) to h3 (the first media item)

in eligibility start, there is an intervening h2 that keeps the order correct

this change allows a child media item to override the heading tag, while maintaining
the h3 styling for all media-item--heading, regardless of tag used

the default tag remains h3 if a child media item does not choose to override
  • Loading branch information
thekaveman committed Mar 22, 2024
1 parent 31b486c commit 93293f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions benefits/core/templates/core/includes/media-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
{% endblock icon %}
</div>
<div class="media-body">
<h3 class="media-body--heading">
{% block heading_wrapper %}
<{{ heading_tag|default:"h3" }} class="media-body--heading h3">
{% block heading %}
{% endblock heading %}
</h3>
</{{ heading_tag|default:"h3" }}>
{% endblock heading_wrapper %}
{% block body %}
{% endblock body %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{% include "core/includes/icon.html" with name="bankcardcheck" %}
{% endblock icon %}

{% block heading_wrapper %}
{% with heading_tag="h2" %}{{ block.super }}{% endwith %}
{% endblock heading_wrapper %}

{% block heading %}
{% translate "The next step is to connect your contactless card to your transit benefit" %}
{% endblock heading %}
Expand Down

0 comments on commit 93293f8

Please sign in to comment.