Skip to content

Conversation

@monishdeb
Copy link
Member

Overview

As per https://www.w3.org/WAI/tutorials/forms/grouping , grouped form controls like radio buttons/checkboxes must be enclosed in <fieldset> and the <legend> element act as a header to identify the group of elements. Currently, when we review such block with WAVE accessibility tool, it complains about:

Proposal

  1. Enclose the checkbox/radio button block in a fieldset
  2. Add a special class to that fieldset say crm-sr-fieldset which hides it in front-end forms (public and backoffice forms)
  3. Use label of checkbox/radio buttons as its legend header.

Before

before-1 before-2

After

after-1 after-2

Comments

ping @colemanw @vingle @seamuslee001

@civibot
Copy link

civibot bot commented Aug 31, 2025

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Aug 31, 2025
@civibot
Copy link

civibot bot commented Aug 31, 2025

The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/3302

}
);
// Copied from `updatePriceSetHighlight()` below which isn't available here.
// Copied from `updatePriceSetHighlight()` below which isn't available here.©
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb is the copywrite icon here necessary?

{assign var="rowCount" value=$rowCount+1}
<div class="price-set-row {$element.name|escape}-row{$rowCount}">
<fieldset class="crm-sr-fieldset">
<legend class="label">{$form.$element_name.label|strip_tags}</legend>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb i just wanted to check if the price field is required does this retain the asterisk sensibly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 good point. This was applied on checkbox option label and I think other then checkbox label asterisk are not appended on Checkbox or Radio field's option. But still I think I will remove this strip_tags usage. Vaguely recall this was causing a accessibility issue but will see later.

width: auto;
}

.crm-container .crm-sr-fieldset {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where style like this should be going but I suppose this is as good as any but thoughts @vingle

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just adding RL support. The problem I've got is that each Stream handles the position of the labels differently. Position:absolute on the legend in Walbrook/Shoreditch gives this:

image

Copy link
Contributor

@krisztin krisztin Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, the current agreed way to reset fieldsets and legends is:

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  display: table;
}

This might help with the RL support

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those resets sound good - but am curious whey the display: table? Mostly RL is using float:left to reset the behaviour of legend centred on the fieldset border - which is maybe ok for some checkbox/radio button groups - but problematic for UI elsewhere. But that works the same with the user-agent default of display:block as table.

Either way @seamuslee001 - would suggest not adding the position absolute. That would need position: relative on the fieldset, then some margins adding (that prob won't work at all sizes).

@seamuslee001
Copy link
Contributor

@monishdeb I think this is a sensible direction, I do want to flag this PR #33466 which whilst not addresing the exact same issue is dealing with a similar siatution (in that case it is about radio / checkbox custom fields) but just not sure how much overlap between the markup is there

@monishdeb
Copy link
Member Author

Thanks @seamuslee001 for your feedback. I have updated the PR to address those points

vingle added a commit to vingle/civicrm-core that referenced this pull request Sep 1, 2025
@vingle
Copy link
Contributor

vingle commented Sep 1, 2025

This looks good - just trying to make it work in RL then will PR to this branch.

FTR - there's another active PR with another accessible radio/checkbox pattern that doesn't use fieldset/legend but just the divs there:
https://github.com/civicrm/civicrm-core/pull/33466/files#diff-6848a25bfee634154a321db3c9c9125345b96609e62dcf7155ecbdd4d4fe4f64

For radios that sets role=radiogroup on the container with an aria-labelledby, and for checkboxes does something similar with role=group - an accessible pattern described here.

vingle added a commit to vingle/civicrm-core that referenced this pull request Sep 1, 2025
@vingle
Copy link
Contributor

vingle commented Sep 1, 2025

In case you don't change this to the div pattern - which would mean themes don't have to unset the fieldset/legend browser defaults - I've added a PR to make this compatible with all four current streams in RiverLea: JMAConsulting#141 - which has required adding a new RL variable.

@monishdeb
Copy link
Member Author

Thank you @vingle for suggesting the div pattern and also to extend the current fieldset approach to support RL. I'll take a look and update the patch accordingly.

@vingle
Copy link
Contributor

vingle commented Oct 23, 2025

@monishdeb that PR has been merged - #33466 - perhaps you can check if this is still needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants