Alternative KISS solution for #504962: Provide a compound form element with accessible labels

Requires changes from #2002336: Introduce a CSS class to hide borders of fieldset elements as base building block.

The interdiff contains the (minimal) changes requires on top of #2002336.

I do think it would be good to explain why it is better than #504962-228: Provide a compound form element with accessible labels but it meets the desired results from an accessibility point of view.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, form.composite.0.patch, failed testing.

sun’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
8.37 KB
5.12 KB
  1. Added missing/expected support for #field_prefix/#field_suffix to theme_fieldset().
  2. Added expected support for required marker in legend to theme_fieldset().

Interdiff is still against parent issue.

mgifford’s picture

FileSize
89.42 KB
154.75 KB
600.98 KB

Well, WAVE likes it:

wave results for accessibility

This applies nicely. Still has that weird formatting issue:

configuration forms a bit off

Thanks @sun!

sun’s picture

Status: Needs review » Postponed
mgifford’s picture

Status: Postponed » Needs review

Great to see the CSS issue in Core.

sun’s picture

FileSize
5.12 KB

Rebased — now contains changes for #type radios and checkboxes only.

mgifford’s picture

FileSize
5.23 KB
226.59 KB

This seems to work just fine. Just noticed that the CSS changes such that the Legend is in all caps. Rerolled adding text-transform: none;

.form-composite > legend,
h4.label {
  font-size: inherit;
  font-weight: bold;
  margin: 0;
  padding: 0;
  text-transform: none;
}
sun’s picture

Status: Needs review » Needs work

That text-transform for fieldset legends and details summaries is custom to the Seven theme, and therefore the Seven theme is responsible for not setting it for .form-composite.

The default theme styles in system.theme.css are only for setting basic styles.

sun’s picture

Status: Needs work » Needs review
FileSize
5.67 KB
1.26 KB
  1. Fixed Seven theme should not uppercase legend of .form-composite fieldsets.
  2. Fixed missing vertical spacing between multiple consecutive fieldsets.

Interdiff is against #6.

mgifford’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

This looks great! I'm marking this RTBC. It does what needs to be done from an accessibility/semantic point of view.

falcon03’s picture

Priority: Normal » Critical

Bumping priority. This is a critical issue if we want to comply with WCAG 2.0...

mgifford’s picture

Priority: Critical » Major

Critical for WCAG 2.0 AA, but not for the Drupal definition of Critical.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

mgifford’s picture

Ok, time for a little dance of joy! Thanks @catch. This has been a very long time coming!

@sun - really appreciate your efforts on both patches!

tim.plunkett’s picture

+++ b/core/includes/form.inc
@@ -1259,7 +1278,10 @@ function form_pre_render_conditional_form_element($element) {
-    $element['#theme_wrappers'][] = 'form_element';
...
+    $element['#theme_wrappers'][] = 'fieldset';

This means that if you are using template_preprocess_form_element or form-element.html.twig, you can affect all form elements, except checkboxes and radios.

I think this is a regression.

See #1493324: Inline form errors for accessibility and UX

mgifford’s picture

Status: Fixed » Needs work

Ok, so for now I'm bringing this back to Needs work. If this needs to be addressed in a new issue, fine.

sun’s picture

Status: Needs work » Fixed

I just followed up on #1493324-165: Inline form errors for accessibility and UX and presented a plan to move forward.

In short, we should do #2152209: Convert theme_fieldset() to Twig first, then consolidate.

tim.plunkett’s picture

I think this should be reverted until #2152209: Convert theme_fieldset() to Twig is resolved.

joelpittet’s picture

@tim.plunkett i've re-rolled theme_fieldset. Hope that help.

tim.plunkett’s picture

Title: Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes » REGRESSION: Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes
Status: Fixed » Needs work

Please revert. Converting theme_fieldset needs to happen before this issue, so that radios and checkboxes are not turned into second class citizens.

sun’s picture

Title: REGRESSION: Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes » Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes

#2152209: Convert theme_fieldset() to Twig is RTBC already.

In addition, #1493324: Inline form errors for accessibility and UX is not "blocked" by any of these changes. As with any other commit to HEAD, other change proposals may need to be adapted. That's no news.

The Accessibility team has been waiting for the required WCAG compliance fix here since 2009. This is not a regression.

joelpittet’s picture

Wanted to reference this issue that I was working on here to remove the theme_form_required_marker() and replace it with CSS.
#2152217: Remove theme_form_required_marker() from the theme system - use CSS instead

Wim Leers’s picture

YesCT’s picture

Would #2275373: Add function for shared logic between fieldset and form element help for the problem mentioned in #15?

Or is what we need a different issue (title?) like "make template_preprocess_form_element or form-element.html.twig, affect all form elements, including checkboxes and radios" by ... I dont know what to write in the "by" part.

mgifford’s picture

This issue and it's related spinoffs seems to be stalled. I'm not sure how to get us @YesCT I'm not sure how to move us beyond this.

Think we need direction from @sun & @tim.plunkett at this point.

joelpittet’s picture

Can we revert this, maybe there is a way we can get the form_element's tag to swap out or some other less invasive surgical array manipulations, but this seems to have hindered the inline error messages issue by quite a bit.

#1493324: Inline form errors for accessibility and UX

mgifford’s picture

If I could only have one in 8.0.0. I'd choose good inline form errors over fieldsets for radios & checkboxes.

A considerable amount of work has gone into both, but better error messages will benefit everyone.

rooby’s picture

What is the technical reason why form errors can't be made to work with this patch?

tim.plunkett’s picture

See #15 for the problematic change. Instead of being treated like a form element, it is added to a fieldgroup. Form errors are for form elements. Making checkboxes and radios form elements would mean undoing the fieldgroup changes.

rooby’s picture

I see what you mean by form errors are for form elements.

Is there a nice way to still have the form_element theme wrapper and still end them up wrapped in a fieldset, or is that going to end up too hacky? (sorry for being lazy and not actually investigating for myself, but I figure someone has possibly already investigated it.)

I feel both these issues are important.

tim.plunkett’s picture

I believe last time we tried that, it ended up with two labels and descriptions, see #1493324-225: Inline form errors for accessibility and UX

mgifford’s picture

Any chance that this problem changed now that #1493324: Inline form errors for accessibility and UX is in Core? There were over 300 comments between that post & the commit so hoping perhaps we won't still have two labels and descriptions with this approach to radios & checkboxes. A lot has changed since #9 though.

mgifford’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs work » Postponed
mgifford’s picture

Status: Postponed » Needs review

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed 2c7b99d on 8.3.x
    Issue #2192419 by sun, mgifford: Use a WCAG-compliant fieldset (...

  • catch committed 2c7b99d on 8.3.x
    Issue #2192419 by sun, mgifford: Use a WCAG-compliant fieldset (...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

Looks it was commited

YesCT’s picture

@andypost #36and #37 are automated messages, due to the branch/release automated changes and the commit in #13 http://cgit.drupalcode.org/drupal/commit/?id=2c7b99d from 2014-02-20

I'm not sure why it was set to needs review by @mgifford in #34

Maybe (the "new") https://www.drupal.org/governance/core can identify people who can clarify how this should be closed, and what issue is for the current work is (or a new issue for revert. It has probably too late to be a "revert" and would have to be new work (and an issue) to change it).

mgifford’s picture

Status: Needs review » Needs work

@YesCT - Probably Needs Work would be better. The code in #9 is way old.

  • catch committed 2c7b99d on 8.4.x
    Issue #2192419 by sun, mgifford: Use a WCAG-compliant fieldset (...

  • catch committed 2c7b99d on 8.4.x
    Issue #2192419 by sun, mgifford: Use a WCAG-compliant fieldset (...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Status: Needs work » Fixed
Issue tags: -Needs subsystem maintainer review, -Needs framework manager review

This issue should never have been committed.
But after it was decided to not be reverted, it should have closed.

This issue has caused a massive amount of ripple effect through other issues, but they all adapted eventually. Let's just close this one out for good.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.