Skip to content

fix: Add visual invalid input handling beyond color#10101

Merged
lizschwab merged 4 commits into
RaspberryPiFoundation:mainfrom
lizschwab:9684
Jul 8, 2026
Merged

fix: Add visual invalid input handling beyond color#10101
lizschwab merged 4 commits 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

Comment thread packages/blockly/core/field_input.ts Outdated
}

/** 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

Comment thread packages/blockly/core/field_input.ts Outdated
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.

Comment thread packages/blockly/core/field_input.ts Outdated
}

/** 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch; this was leftover from a different approach I was taking earlier on. I'll remove it.

@lizschwab lizschwab requested a review from maribethb July 7, 2026 21:23
Comment thread packages/blockly/core/field_input.ts Outdated
import type {IFocusableNode} from './interfaces/i_focusable_node.js';
import {Msg} from './msg.js';
import * as renderManagement from './render_management.js';
import {Svg} from './utils.js';

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 think you might want to have this import from ./utils/svg.js (similar to other imports from utils/ dir in this file) because sometimes importing from the whole utils.js file causes issues eventually

Comment thread packages/blockly/core/field_input.ts Outdated
Svg.PATH,
{
'd': 'M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z',
'stroke': '#1f1f1f',

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'm somewhat iffy in my knowledge on styling svg with css, but i think if you move the stroke and fill properties to a css class it would let users customize the look of this easier if they want to. hardcoding it is really hard to override, i think. aaron may be more knowledgeable here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe you're correct. It's easy enough to move to css.

@lizschwab lizschwab requested a review from maribethb July 7, 2026 21:59
@lizschwab lizschwab merged commit fee09fb into RaspberryPiFoundation:main Jul 8, 2026
8 of 9 checks passed
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