Bug that I initially saw

With the popular bootstrap theme, the radio buttons in the select columns are missing.

The fault is both Diff and Bootstrap - and arguably more from Bootstrap (and I will raise an issue on that project next). However I think there is a worthwhile change to make in this module.

Underlying cause in Diff

In function buildSelectColumn, the Diff module doesn't set a title. Drupal documentation for template_preprocess_form_element states

If the #title property is not set, then the label and any required marker will not be output, regardless of the #title_display or #required values. This can be useful in cases such as the password_confirm element, which creates children elements that have their own labels and required markers, but the parent element should have neither. Use this carefully because a field without an associated label can cause accessibility challenges.

I don't have much experience of accessibility, but the above quote makes me think that for accessibility it is probably better to have a title set, even though #title_display is 'invisible'. I guess that a screen reader might read out the invisible title to help a partially-sighted user understand the purpose of the radio. Without the title, users might have no clue what the radio is for if they can't see the visual alignment.

Setting the title also fixes bug where the buttons disappear with Bootstrap theme.

Underlying cause in Bootstrap

In FormElement::preprocessElement Bootstrap chooses to convert a single radio field into a label. (Not sure why - maybe as an optimisation to reduce HTML??) Unfortunately, the code doesn't first check that the label will actually be displayed.

Comments

AdamPS created an issue. See original summary.

AdamPS’s picture

Has now been fixed in bootstrap #2831650: Bootstrap 3.1 upgrade somehow broke my custom form element.

Up to maintainers if they feel an invisible title is beneficial or if they prefer to close this as won't fix.

mgifford’s picture

Issue tags: +Accessibility

Tagging.