Skip to content

Commit 9cb00e3

Browse files
fix(components): tooltip button must be type="button" (#230)
1 parent eb9ff15 commit 9cb00e3

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

dsfr/templates/dsfr/tooltip.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% load i18n %}
22
{% if self.is_clickable|default:False %}
3-
<button class="fr-btn--tooltip fr-btn"
3+
<button type="button"
4+
class="fr-btn--tooltip fr-btn"
45
id="button-{{ self.id }}"
56
aria-describedby="{{ self.id }}">
67
{% translate "Contextual information" %}

dsfr/test/test_templatetags.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,37 @@ def test_tooltip_rendered(self):
11171117
rendered_template,
11181118
)
11191119

1120+
def test_clickable_tooltip_rendered(self):
1121+
test_data = {
1122+
"content": "Contenu d’une infobule activée au survol",
1123+
"label": "Libellé du lien",
1124+
"id": "tooltip-test",
1125+
"is_clickable": True,
1126+
}
1127+
1128+
context = Context({"test_data": test_data})
1129+
template_to_render = Template(
1130+
"{% load dsfr_tags %} {% dsfr_tooltip test_data %}"
1131+
)
1132+
rendered_template = template_to_render.render(context)
1133+
self.assertInHTML(
1134+
"""
1135+
<button type="button"
1136+
class="fr-btn--tooltip fr-btn"
1137+
id="button-tooltip-test"
1138+
aria-describedby="tooltip-test"
1139+
>
1140+
Information contextuelle
1141+
</button>
1142+
1143+
<span class="fr-tooltip fr-placement"
1144+
id="tooltip-test"
1145+
role="tooltip"
1146+
aria-hidden="true">Contenu d’une infobule activée au survol</span>
1147+
""",
1148+
rendered_template,
1149+
)
1150+
11201151

11211152
class DsfrTranscriptionTagTest(SimpleTestCase):
11221153
test_data = {

0 commit comments

Comments
 (0)