Compare commits

..

1 Commits

Author SHA1 Message Date
Frédéric Péters 07e6d62f4e a11y: add group role to blocks (#88620)
gitea/wcs/pipeline/head This commit looks good Details
2024-03-25 14:13:34 +01:00
1 changed files with 7 additions and 3 deletions

View File

@ -462,7 +462,6 @@ class BlockWidget(WidgetList):
template_name = 'qommon/forms/widgets/block.html'
always_include_add_button = True
a11y_role = 'group'
a11y_labelledby = True
def __init__(
self,
@ -500,6 +499,10 @@ class BlockWidget(WidgetList):
**kwargs,
)
@property
def a11y_labelledby(self):
return bool(self.title and self.label_display != 'hidden')
def set_value(self, value):
from .fields.block import BlockRowValue
@ -568,8 +571,9 @@ class BlockWidget(WidgetList):
def render_title(self, title):
attrs = {'id': 'form_label_%s' % self.get_name_for_id()}
if not title or self.label_display == 'hidden':
attrs = {'class': 'sr-only'}
return htmltag('span', **attrs) + htmltext('%s</span>') % (title or '')
# add a tag even if there's no label to display as it's uses as an anchor point
# for links to errors.
return htmltag('div', **attrs) + htmltext('</div>')
if self.label_display == 'normal':
return super().render_title(title)