Forms: required checkbox and radio groups don't link their fieldset to the error message

Abierto Apto para principiantes
#54,575 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, wordpress

Línea de trabajo

Empieza en projects/packages/forms/src/contact-form/class-contact-form-field.php y compara get_described_by() con el marcado de los fieldsets de radio y casillas de verificación alrededor de las líneas citadas. Reproduce el problema con el formulario proporcionado con campos obligatorios, envíalo vacío e inspecciona si el aria-describedby de cada fieldset apunta a su mensaje de error. Se considera terminado cuando ambos grupos exponen esa descripción accesible; el issue no menciona ningún archivo de prueba.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Needs triage
Impacted plugin

Jetpack

Quick summary

When a required single input fails validation, it gets aria-describedby pointing at its error message. Required checkbox and radio groups don't: the fieldset gets aria-invalid="true", but nothing references the error message.

After clicking Submit on an empty form:

Field aria-invalid aria-describedby Accessible description in Chromium
Required text input true g4-yourname-text-error-message "This field is required."
Required field-checkbox-multiple fieldset true none empty
Required radio fieldset true none empty

The error messages exist, as g4-picksome-select-error-message and g4-pickone-radio-error-message. The individual checkbox and radio inputs don't reference them either. The visible error therefore isn't programmatically associated with its group (relevant to WCAG 1.3.1).

Single inputs get the link from get_described_by(), but the group fieldset tags don't use it (radio, checkbox). Adding it there looks like the fix, with type radio for radio groups and select for checkbox groups, but I haven't tried that change.

Steps to reproduce
  1. Add this form to a page, with Jetpack's Forms module active:
<!-- wp:jetpack/contact-form -->
<div class="wp-block-jetpack-contact-form">
<!-- wp:jetpack/field-text {"required":true} -->
<div class="wp-block-jetpack-field-text"><!-- wp:jetpack/label {"label":"Your name","required":true} /-->
<!-- wp:jetpack/input /--></div>
<!-- /wp:jetpack/field-text -->
<!-- wp:jetpack/field-checkbox-multiple {"required":true} -->
<div class="wp-block-jetpack-field-checkbox-multiple"><!-- wp:jetpack/label {"label":"Pick some","required":true} /-->
<!-- wp:jetpack/options -->
<ul class="wp-block-jetpack-options"><!-- wp:jetpack/option {"label":"Red"} /-->
<!-- wp:jetpack/option {"label":"Blue"} /--></ul>
<!-- /wp:jetpack/options --></div>
<!-- /wp:jetpack/field-checkbox-multiple -->
<!-- wp:jetpack/field-radio {"required":true} -->
<div class="wp-block-jetpack-field-radio"><!-- wp:jetpack/label {"label":"Pick one","required":true} /-->
<!-- wp:jetpack/options -->
<ul class="wp-block-jetpack-options"><!-- wp:jetpack/option {"label":"Yes"} /-->
<!-- wp:jetpack/option {"label":"No"} /--></ul>
<!-- /wp:jetpack/options --></div>
<!-- /wp:jetpack/field-radio -->
<!-- wp:jetpack/button {"element":"button","text":"Submit"} /-->
</div>
<!-- /wp:jetpack/contact-form -->
  1. View the page logged out and click Submit with everything empty.
  2. Inspect the text input and both fieldset elements.

Expected: each fieldset has aria-describedby pointing at its error message, as the text input does.

Actual: each fieldset has aria-invalid="true" and no aria-describedby.

Tested on

  • Jetpack 16.3.1 (Forms package 8.3.2) and 16.4 (Forms package 8.3.7), with the same result on both. The fieldset code looks the same on trunk, from reading the source only.
  • WordPress 7.1.4, PHP 8.3, Twenty Twenty-Five, only Jetpack active, on WordPress Playground in Jetpack offline mode.
  • Headless Chromium 156. Both inner-block field markup and attribute-style markup behave the same.

I checked Chromium's accessibility tree, not a real screen reader. I only ran the default form style. No console errors.

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Moderate

What other impact(s) does this issue have?

No revenue impact

If a workaround is available, please outline it here.

Site code can add aria-describedby to the fieldset, pointing at the error message's ID.

Platform (Simple and/or Atomic)

Self-hosted

Lenguaje dominante
PHP
Estrellas
1.9k
Forks
906
Merge medio
1 d 18 h
PR fusionados (30 d)
793

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Automattic/jetpack

Todos los issues de Automattic/jetpack

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.