From 51b4f4f394449ae6eba8c477e599e194be6ef4bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Wed, 9 Nov 2022 10:56:46 +0100
Subject: [PATCH] a11y: use <p> for labels on summary page (#71176)

---
 tests/backoffice_pages/test_submission.py | 4 ++--
 tests/form_pages/test_all.py              | 4 ++--
 tests/form_pages/test_live.py             | 8 ++++----
 wcs/fields.py                             | 2 +-
 wcs/forms/common.py                       | 6 +++---
 wcs/qommon/static/css/qommon.scss         | 3 ++-
 6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/tests/backoffice_pages/test_submission.py b/tests/backoffice_pages/test_submission.py
index 305935043..a7b2a4465 100644
--- a/tests/backoffice_pages/test_submission.py
+++ b/tests/backoffice_pages/test_submission.py
@@ -765,8 +765,8 @@ def test_backoffice_submission_live_condition(pub):
     assert 'name="f2"' not in resp.text
     resp = resp.form.submit('submit')
     resp = resp.follow()
-    assert '<span class="label">Bar</span>' in resp.text
-    assert '<span class="label">Foo</span>' not in resp.text
+    assert '<p class="label">Bar</p>' in resp.text
+    assert '<p class="label">Foo</p>' not in resp.text
 
 
 def test_backoffice_submission_conditional_jump_based_on_bo_field(pub):
diff --git a/tests/form_pages/test_all.py b/tests/form_pages/test_all.py
index f0c4d6d62..cc8066203 100644
--- a/tests/form_pages/test_all.py
+++ b/tests/form_pages/test_all.py
@@ -7661,8 +7661,8 @@ def test_field_condition(pub):
     assert 'name="f2"' not in resp.text
     resp = resp.form.submit('submit')
     resp = resp.follow()
-    assert '<span class="label">Bar</span>' in resp.text
-    assert '<span class="label">Foo</span>' not in resp.text
+    assert '<p class="label">Bar</p>' in resp.text
+    assert '<p class="label">Foo</p>' not in resp.text
 
 
 def test_field_unicode_condition(pub):
diff --git a/tests/form_pages/test_live.py b/tests/form_pages/test_live.py
index a625f7b09..9e293c8b2 100644
--- a/tests/form_pages/test_live.py
+++ b/tests/form_pages/test_live.py
@@ -79,8 +79,8 @@ def test_field_live_condition(pub):
     assert 'name="f2"' not in resp.text
     resp = resp.form.submit('submit')
     resp = resp.follow()
-    assert '<span class="label">Bar</span>' in resp.text
-    assert '<span class="label">Foo</span>' not in resp.text
+    assert '<p class="label">Bar</p>' in resp.text
+    assert '<p class="label">Foo</p>' not in resp.text
 
     resp = get_app(pub).get('/foo/')
     assert 'f1' in resp.form.fields
@@ -96,8 +96,8 @@ def test_field_live_condition(pub):
     assert 'name="f2"' in resp.text
     resp = resp.form.submit('submit')
     resp = resp.follow()
-    assert '<span class="label">Bar</span>' in resp.text
-    assert '<span class="label">Foo</span>' in resp.text
+    assert '<p class="label">Bar</p>' in resp.text
+    assert '<p class="label">Foo</p>' in resp.text
 
 
 def test_field_live_condition_on_other_page(pub):
diff --git a/wcs/fields.py b/wcs/fields.py
index d960b3312..196b4a8e3 100644
--- a/wcs/fields.py
+++ b/wcs/fields.py
@@ -3926,7 +3926,7 @@ class BlockField(WidgetField):
                 if field.extra_css_class:
                     css_classes.append(field.extra_css_class)
                 r += htmltext('<div class="%s">' % ' '.join(css_classes))
-                r += htmltext('<span class="label">%s</span> ') % field.label
+                r += htmltext('<p class="label">%s</p> ') % field.label
                 sub_value, sub_value_details = field.get_value_info(row_value)
                 if sub_value is None:
                     r += htmltext('<div class="value"><i>%s</i></div>') % _('Not set')
diff --git a/wcs/forms/common.py b/wcs/forms/common.py
index df905920f..3f2a13c2c 100644
--- a/wcs/forms/common.py
+++ b/wcs/forms/common.py
@@ -505,7 +505,7 @@ class FormStatusPage(Directory, FormTemplateMixin):
         r += htmltext('<div class="dataview">')
 
         if user:
-            r += htmltext('<div class="field username"><span class="label">%s</span>') % _('User name')
+            r += htmltext('<div class="field username"><p class="label">%s</p>') % _('User name')
             r += htmltext('<span class="value">%s</span></div>') % user.display_name
 
         r += self.display_fields(form_url=form_url)
@@ -515,7 +515,7 @@ class FormStatusPage(Directory, FormTemplateMixin):
         ):
             wf_status = self.filled.get_visible_status(user=get_request().user)
             if wf_status:
-                r += htmltext('<div class="field status"><span class="label">%s</span> ') % _('Status')
+                r += htmltext('<div class="field status"><p class="label">%s</p> ') % _('Status')
                 r += htmltext('<span class="value">%s</span></div>') % wf_status.name
 
         r += htmltext('</div>')  # .dataview
@@ -567,7 +567,7 @@ class FormStatusPage(Directory, FormTemplateMixin):
             if f.key == 'block' and f.label_display == 'subtitle':
                 r += htmltext('<div class="subtitle"><h4>%s</h4></div>') % f.label
             elif not (f.key == 'block' and f.label_display == 'hidden'):
-                r += htmltext('<span class="label">%s</span> ') % f.label
+                r += htmltext('<p class="label">%s</p> ') % f.label
             value, value_details = field_value_info['value'], field_value_info['value_details']
             if value is None:
                 if not (f.key == 'block' and f.label_display == 'hidden'):
diff --git a/wcs/qommon/static/css/qommon.scss b/wcs/qommon/static/css/qommon.scss
index a5c25c8eb..23d3ca5fe 100644
--- a/wcs/qommon/static/css/qommon.scss
+++ b/wcs/qommon/static/css/qommon.scss
@@ -253,9 +253,10 @@ div.dataview div.field {
 	margin: 1em 0;
 }
 
-div.dataview span.label {
+div.dataview .label {
 	font-weight: bold;
 	display: block;
+	margin: 0;
 }
 
 div.dataview .value {
-- 
2.38.1

