Skip to content

fix: Add visual invalid input handling beyond color#10101

Open
lizschwab wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
lizschwab:9684
Open

fix: Add visual invalid input handling beyond color#10101
lizschwab wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
lizschwab:9684

Conversation

@lizschwab

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #9684

Proposed Changes

Added a warning icon which is displayed when a field's input is invalid. This is to address the Use of Color WCAG guidelines.

Zelos Renderer

Screenshot 2026-07-02 at 3 12 37 PM Screenshot 2026-07-02 at 3 13 20 PM Screenshot 2026-07-02 at 3 13 49 PM Screenshot 2026-07-02 at 3 14 01 PM

Zoomed in:
Screenshot 2026-07-02 at 3 19 08 PM
Screenshot 2026-07-02 at 3 19 18 PM
Screenshot 2026-07-02 at 3 20 58 PM
Screenshot 2026-07-02 at 3 36 51 PM

Zoomed out:
Screenshot 2026-07-02 at 3 23 11 PM
Screenshot 2026-07-02 at 3 23 18 PM
Screenshot 2026-07-02 at 3 23 54 PM
Screenshot 2026-07-02 at 3 24 02 PM

RTL:
Screenshot 2026-07-02 at 3 26 47 PM
Screenshot 2026-07-02 at 3 26 52 PM
Screenshot 2026-07-02 at 3 26 59 PM
Screenshot 2026-07-02 at 3 27 07 PM

Geras Renderer

Screenshot 2026-07-02 at 3 17 06 PM Screenshot 2026-07-02 at 3 40 22 PM Screenshot 2026-07-02 at 3 17 41 PM Screenshot 2026-07-02 at 3 17 55 PM

Zoomed in:
Screenshot 2026-07-02 at 3 22 12 PM
Screenshot 2026-07-02 at 3 22 18 PM
Screenshot 2026-07-02 at 3 21 52 PM
Screenshot 2026-07-02 at 3 22 00 PM

Zoomed out:
Screenshot 2026-07-02 at 3 24 35 PM
Screenshot 2026-07-02 at 3 24 43 PM
Screenshot 2026-07-02 at 3 24 51 PM
Screenshot 2026-07-02 at 3 24 58 PM

RTL:

Screenshot 2026-07-02 at 3 25 46 PM Screenshot 2026-07-02 at 3 25 54 PM Screenshot 2026-07-02 at 3 26 01 PM Screenshot 2026-07-02 at 3 26 08 PM

Test Coverage

Tests added to ensure icon is added appropriately and aria-invalid state is set.

@lizschwab lizschwab requested a review from a team as a code owner July 2, 2026 22:50
@lizschwab lizschwab requested a review from maribethb July 2, 2026 22:50
@github-actions github-actions Bot added the PR: fix Fixes a bug label Jul 2, 2026

@maribethb maribethb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

adding a new media url is a breaking change, as discussed offline, but reviewed the rest of it

}

/** Creates the DOM elements for the invalid input warning icon. */
private createWarningIcon(parent?: Element | null): HTMLImageElement | null {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd go ahead and make this protected so that subclasses can modify it if desired

if (!this.isTextValid_) {
dom.addClass(htmlInput, 'blocklyInvalidInput');
aria.setState(htmlInput, aria.State.INVALID, true);
// insert the icon

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd probably move this logic to a function call to keep the render_ method smaller and make it easier for subclasses to also call that function in case they override render.

}

/** Creates the DOM elements for the invalid input warning icon. */
private createWarningIcon(parent?: Element | null): HTMLImageElement | null {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you need to accept the parent as a parameter? you only call this in one place and you don't pass it in, you just append it manually to the dom after creation. I would remove this unless I'm overlooking something

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

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update field validation to meet WCAG

2 participants