Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 290956

Radios element missing "required" attribute

$
0
0

Problem/Motivation

The radios elements that are provided by core do not apply the required attribute to the generated <input> elements. Instead the required attribute is applied to the wrapping <fieldset>.

There are two issues with this:

  1. screen readers use required attribute on <input type="radio">. If the attribute is not present on the , then the required state will not be communicated to the screen reader user.
  2. the required attribute is not valid when applied to a <fieldset>, thus causing the page to fail W3C validation.

Proposed resolution

  1. Remove the required and aria-required attributes from the <fieldset> of Form API radios elements.
  2. Add required attribute to the <input type=radio> elements instead.
  3. CSS updates, to ensure no visual regression in Seven and Bartik.

Remaining tasks

  • Remove required + and aria-required attributes from the <fieldset> element to the <input> element.
  • DONE. Add the required="required"<code> attribute to the <code><input type="radio"> elements.
  • CSS to avoid visual regression. Asterisk should be after the fieldset legend, not the individual radio buttons.
  • Evaluate impact on Classy - Can the CSS go into Classy? - Classy is removed from D10 so may be non issue
  • Tests? Appear to have been added

Manual testing tips

We need a required radios element to test this, e.g. add a "favourite colour" field to a content type. Use a field of type "List", mark it required, and use the radios/checkboxes widget under "manage form display".

User interface changes

Markup + CSS changes to

  1. Fix invalid HTML
  2. Convey required radio buttons correctly to assistive tech.
  3. Avoid visual regression.

API changes

None.

Data model changes

None.

Original report by @mfairchild365

This issue is split off from #2950999: Checkboxes element missing "required" attribute. That issue originally addressed radios and checkboxes, but it looks like they need different solutions, so we're using separate issues now.


Viewing all articles
Browse latest Browse all 290956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>