Skip to content

Update field validation to meet WCAG #9684

Closed

Description

@rachel-fenichel

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

Text field validators, and particularly number fields, can turn red to show errors or reset the value if not valid. This needs to be updated to fully comply with these WCAG rules:

Activity

  1. removed
    status: triageIssues awaiting triage by a Blockly team member
    on Apr 7, 2026
  2. self-assigned this
    on May 15, 2026
  3. moved this from Todo to In Progress in Blocklyon May 18, 2026
  4. lizschwab commented on May 18, 2026

    @lizschwab
    Contributor

    @rachel-fenichel I am assuming this is focused on the text and number inputs and not the dropdown, checkbox, or variable validators, is that correct?

  5. rachel-fenichel commented on May 18, 2026

    @rachel-fenichel
    CollaboratorAuthor

    Correct. I believe the others don't let you enter a bad value.

  6. maribethb commented on Jun 23, 2026

    @maribethb
    Contributor

    I think it's going to be difficult to provide a text-based warning. Developers can subclass FieldInput and put any kind of constraints they want on the validator, so we have no way of generating a textual message, and up to now there has not been a way to provide one, so it would be a breaking change to require one.

    We could add an option to show one, but we need to have a plan for the (probably majority) of cases where we don't have one. And we need to make sure that we don't show a default message that doesn't make sense for subclasses where the developer hasn't overridden it yet.

    From 3.3.1:

    For instance, "Email is not valid" would pass 3.3.1,

    This isn't really a useful message, but "value is not valid" is text that seems like it would pass this criteria. Could simply adding a warning icon, perhaps with this vague/generic text as alt/tooltip text, pass this criteria?

    3.3.2:

    Labels or instructions are provided when content requires user input.

    I think we have to assume that the text on the block already provides this. This isn't only related to error validation, so if we're proposing a different change to input fields to meet this criteria, that needs to be in a different issue. Under a strict reading of this, the number block on its own doesn't provide any label or instructions. But adding an explicit Enter a number label to every number block would be a huge, disruptive change, and imo probably actively harmful to the block-based programming learning experience. So I'm going to assume that we are not changing anything for this criteria.

    3.3.3:

    If an input error is automatically detected and suggestions for correction are known, then the suggestions are provided to the user, unless it would jeopardize the security or purpose of the content.

    (emphasis mine) We generally do not know suggestions for correction because developers can do anything they want with validation, so I do not see how we can address this criteria within the library. If we added the ability for field authors to provide a custom message then we could encourage them to meet this criteria with their message.

    1.4.1:

    Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element.

    This is the main one we are currently breaking and I think the best user experience would be to show an additional warning icon inline with the field in addition to the color change, as well as setting aria-invalid to make sure it's announced to screenreaders.

  7. rachel-fenichel commented on Jun 23, 2026

    @rachel-fenichel
    CollaboratorAuthor

    I agree with your reading, that the main thing we need to fix is 1.4.1 and 3.3.1 by adding an inline warning icon and setting aria-invalid.

  8. added theissue type on Jul 8, 2026
  9. moved this from In Progress to Done in Blocklyon Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions