Skip to content

feat(ui): dispatch validation events from TextField#609

Merged
gspencergoog merged 2 commits intomainfrom
feature/regex-event-clean
Feb 18, 2026
Merged

feat(ui): dispatch validation events from TextField#609
gspencergoog merged 2 commits intomainfrom
feature/regex-event-clean

Conversation

@dmandar
Copy link
Collaborator

@dmandar dmandar commented Feb 9, 2026

This PR introduces the a2ui-validation-input event to the
TextField
component to bubble validation state changes.

Changes
TextField (
text-field.ts
):
Added dispatch of a2ui-validation-input on every input event.
Payload: { componentId, value, valid: boolean }.
Reason: Native invalid events do not cross the Shadow DOM boundary. This custom event allows parent components (like the Shell) to observe real-time validation status.
Component Gallery (
component-gallery.ts
):
Added a listener for a2ui-validation-input at the document root.
Logs validation events to both the Console and the internal Debug Panel for visual verification.
Verification
Verified manually in the Component Gallery:
Typing in "TextField (Regex)" now triggers logs in the Debug Panel.
Valid/Invalid states strictly match the regex rules.

Pre-launch Checklist

  • [X ] I signed the CLA.
  • [ X] I read the Contributors Guide.
  • [ X] I read the Style Guide.
  • [ X] I have added updates to the CHANGELOG.
  • [ X] I updated/added relevant documentation.
  • [ X] My code changes (if any) have tests.

If you need help, consider asking for advice on the discussion board.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new a2ui-validation-input event dispatched from the TextField component to communicate validation state changes. The changes look good and achieve the goal. I've added a couple of minor suggestions to improve code style and robustness.

Copy link
Collaborator

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Comment about having a specific, shared type for the failed/passed validation event in web_core!

…t catalog formatting.

This PR introduces a strictly typed A2UIValidationEvent in web_core using the BaseEventDetail pattern to ensure type safety across renderers and clients. The TextField and Component Gallery have been updated to utilize this new event structure, and formatting-only changes in standard_catalog_definition.json were reverted while preserving the new variant and filterable properties for MultipleChoice.
Copy link
Collaborator

@ditman ditman left a comment

Choose a reason for hiding this comment

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

This LGTM, but I really think we shouldn't reexport from web_core. Instead, we should re-export from the lit renderer Events namespace.

(There's a similar problem to this with the styles. The Lit renderer only reexports the ones coming from web_core, instead of its internal version, so application users that want to use the basic styling for their own components, must use unsafeCSS, but that's a fix for another day :P)

Comment on lines +25 to +26
import { Events as WebEvents } from "@a2ui/web_core";
export { Types, Guards, Schemas, Styles, A2uiMessageProcessor, Primitives, WebEvents };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of importing and renaming here, how about exporting these events from web_core directly from ./events/events.js so they become part of the Events namespace offered by the lit renderer?

I think it's a little bit of an anti-pattern to re-export directly from web_core (unless you're coding an actual renderer?)

@dmandar dmandar force-pushed the feature/regex-event-clean branch from 2ced88d to cf5bf5b Compare February 18, 2026 18:33
@gspencergoog gspencergoog merged commit 3b2fb20 into main Feb 18, 2026
18 checks passed
@gspencergoog gspencergoog deleted the feature/regex-event-clean branch February 18, 2026 19:09
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

Comments