Skip to content

Validations for select component. - #2510

Merged
nuke-ellington merged 13 commits into
mainfrom
feat/2595-input-validation-select
Nov 11, 2026
Merged

nuke-ellington merged 13 commits into
mainfrom
feat/2595-input-validation-select

Conversation

@khathija-ahamadi

@khathija-ahamadi khathija-ahamadi commented Apr 21, 2026 •

Copy link
Copy Markdown
Collaborator

💡 What is the current behavior?

There are some errors which prevent validations from happening as expected.

GitHub Issue Number: #1799
JIRA: IX-2595

🆕 What is the new behavior?

The acceptance criteria for this ticket has been met for select component:

Required input:
Invalid input > Removing value with keyboard > Stays invalid
Invalid input > Remove touched state (e.g. clear button) > Valid again
Invalid input > Programmatically setting it to empty > Stays invalid
Valid input > Removing value with keyboard > It is invalid
Valid input > Remove touched state (e.g. autoclear button) > Valid
Valid input > Programmatically setting it to empty > It is invalid

Not required input:
Invalid input > Removing value with keyboard > Valid
Invalid input > Remove touched state (e.g. clear button) > Valid again
Invalid input > Programmatically setting it to empty > Valid
Valid input > Removing value with keyboard > Valid
Valid input > Remove touched state (e.g. clear button) > Valid
Valid input > Programmatically setting it to empty > Valid

Also form 'novalidate' cases is handled.

🏁 Checklist

A pull request can only be merged if all of these conditions are met (where applicable):

  • 🦮 Accessibility (a11y) features were implemented
  • 🗺️ Internationalization (i18n) - no hard coded strings
  • 📲 Responsiveness - components handle viewport changes and content overflow gracefully
  • 📕 Add or update a Storybook story
  • 📄 Documentation was reviewed/updated siemens/ix-docs
  • 🧪 Unit tests were added/updated and pass (pnpm test)
  • 📸 Visual regression tests were added/updated and pass (Guide)
  • 🧐 Static code analysis passes (pnpm lint)
  • 🏗️ Successful compilation (pnpm build, changes pushed)

👨‍💻 Help & support

Summary by CodeRabbit

  • Bug Fixes
    • Improved required-field validation for ix-select in forms, preventing submission when required values are missing unless validation is disabled.
    • Validation now stays synchronized after blur, clearing, and programmatic value changes, including form validity and invalid styling.
  • Enhancements
    • Improved focus behavior and invalid feedback, including support for custom invalid-text.
  • Tests
    • Added coverage for single- and multi-select validation, multiple fields, accessibility, and disabled form validation.

@changeset-bot

changeset-bot Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ae59fb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@siemens/ix Patch
@siemens/ix-angular Patch
@siemens/ix-react Patch
@siemens/ix-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces form validation logic for the ix-select component, including handling for the required attribute, form submission events, and visual error states. It also adds a suite of component tests covering various validation scenarios. The review identified several technical issues: potential memory leaks due to improper event listener cleanup and anonymous functions in connectedCallback, incorrect validity reporting to formInternals which could bypass browser validation, and the need to use standard HTMLFormElement.noValidate properties instead of manual attribute checks.

@khathija-ahamadi khathija-ahamadi changed the title Validations for select components. Validations for select component. Apr 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

@khathija-ahamadi
khathija-ahamadi marked this pull request as ready for review May 5, 2026 01:51
@netlify

netlify Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ix-storybook ready!

Name Link
🔨 Latest commit 0ae59fb
🔍 Latest deploy log https://app.netlify.com/projects/ix-storybook/deploys/6af410dc523535822aecf9fa
😎 Deploy Preview https://deploy-preview-2510--ix-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

@flxlst09 flxlst09 added this to the 5.2.0 milestone Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

ix-select now validates required values during form submission. It synchronizes ElementInternals, validation classes, focus behavior, and form listeners. Tests cover single and multiple selections, novalidate, custom error text, and programmatic value updates.

Changes: Select form validation

Layer / File(s) Summary
Form validation wiring
packages/core/src/components/select/select.tsx
Tracks associated-form submission attempts, handles invalid events, prevents submission for missing required values, and removes listeners during disconnection.
Validation state and feedback
packages/core/src/components/select/select.tsx, packages/core/src/components/select/test/select.ct.ts
Synchronizes ElementInternals validity and required-error classes during value changes, clearing, and blur. Adds host-focus forwarding and ix-invalid input styling. Tests cover required values, multiple selection, novalidate, custom error text, and programmatic updates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Form
  participant IxSelect
  participant ElementInternals
  Form->>IxSelect: submit event
  IxSelect->>IxSelect: record submission attempt
  IxSelect->>ElementInternals: synchronize required validity
  IxSelect-->>Form: prevent submit when value is missing
Loading

Possibly related PRs

  • siemens/ix#2536: Both PRs modify form-associated component validation and required-field state synchronization.
  • siemens/ix#2690: Both PRs modify ix-select validation lifecycle behavior.

Suggested reviewers: nuke-ellington

🚥 Pre-merge checks | ✅ 5

✅ Passed checks (5 passed)

Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies validation changes for the select component, which matches the main purpose of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate docstrings

  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Commit unit tests in branch feat/2595-input-validation-select
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/components/select/select.tsx (1)

1-1: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

novalidate should only suppress interactive validation, not clear validity.

  • packages/core/src/components/select/select.tsx#L576-L607: syncValidationClasses() should keep ElementInternals validity intact when isFormNoValidate() is true; only the invalid-required class/visual feedback should be skipped.
  • packages/core/src/components/select/test/select.ct.ts#L1692-L1719: update the novalidate test to keep form.checkValidity() false for an empty required select and assert only that the invalid UI is hidden.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/components/select/select.tsx` at line 1, Update
syncValidationClasses() so isFormNoValidate() skips only invalid-required
styling and visual feedback while preserving the ElementInternals validity state
for an empty required select. Adjust the novalidate test to assert
form.checkValidity() remains false and verify that invalid UI is hidden.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/components/select/select.tsx`:
- Around line 782-794: Remove the redundant syncValidationClasses() call from
the clear-value method containing emptyValue, since assigning this.value already
triggers the value watcher’s validation-class synchronization. Keep
emitValueChange, dropdown closing, and the onInputBlur synchronization
unchanged.
- Around line 402-407: Store the inline invalid-event callback used in
connectedCallback as a component-level handler reference, then remove that same
reference from hostElement in disconnectedCallback. Ensure reconnecting the
component does not accumulate invalid listeners while preserving the existing
formSubmissionAttempted, touched, and syncValidationClasses behavior.
- Around line 383-407: Update the submit callback assigned to formSubmitHandler
in connectedCallback to check isFormNoValidate() before preventing or stopping
submission for an empty required select. Preserve the existing validation state
updates, but allow submission when novalidate is present and only block required
empty submissions when interactive validation is enabled.
- Around line 576-607: Update syncValidationClasses so isFormNoValidate() only
removes the ix-invalid--required visual class and returns without calling
formInternals.setValidity({}); preserve the existing constraint validity for
required empty selects so checkValidity() and form.checkValidity() remain
invalid.
- Around line 314-321: Update the parentForm getter to return
this.formInternals.form instead of searching with hostElement.closest('form'),
so associated controls using form="..." resolve their owner correctly. Keep
isFormNoValidate() using parentForm and preserve its existing null/false
fallback behavior.

In `@packages/core/src/components/select/test/select.ct.ts`:
- Around line 1599-1779: Enhance the new required/invalid select tests around
the invalid state assertions to include axe-based accessibility coverage using
the established makeAxeBuilder() pattern. Run the accessibility check after
triggering invalid validation, including coverage for the invalid-text feedback
UI, while preserving the existing validation assertions.
- Around line 1753-1779: Remove the fixed page.waitForTimeout(100) call from the
“programmatic value setting updates validation state” test. Let the existing
expect(select).not.toHaveClass assertion poll until the validation class is
removed, preserving the test’s current behavior.

---

Outside diff comments:
In `@packages/core/src/components/select/select.tsx`:
- Line 1: Update syncValidationClasses() so isFormNoValidate() skips only
invalid-required styling and visual feedback while preserving the
ElementInternals validity state for an empty required select. Adjust the
novalidate test to assert form.checkValidity() remains false and verify that
invalid UI is hidden.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8b4d155f-22af-4134-a7b2-86a39522c1c2

📥 Commits

Reviewing files that changed from the base of the PR and between 9e17b20 and 7a91596.

📒 Files selected for processing (2)
  • packages/core/src/components/select/select.tsx
  • packages/core/src/components/select/test/select.ct.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/core/src/components/select/select.tsx (2)

389-408: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add a changeset or state that this change is internal-only.

This changes public ix-select validation and submission behavior. No changeset is included. Add a consumer-focused changeset, or explicitly justify why the change has no release impact.

As per path instructions, “Changesets are required for public API updates, behavior changes, styling/theming changes, accessibility changes, and bug fixes with user impact.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/components/select/select.tsx` around lines 389 - 408, Add a
consumer-focused changeset documenting the public ix-select validation and
form-submission behavior change, including its user-facing impact and
appropriate release bump. Do not treat this as internal-only, since the modified
connectedCallback behavior affects consumers.

Source: Path instructions


393-400: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Honor formnovalidate on the submitter.

A submit button or input can disable constraint validation with formnovalidate. This handler checks only form.noValidate, then prevents submission for an empty required select.

Read SubmitEvent.submitter and skip the custom prevention when its formNoValidate property is true. Add a component test that submits an empty required select through a formnovalidate submitter.

Proposed fix
       this.formSubmitHandler = (event: Event) => {
         this.formSubmissionAttempted = true;
         this.touched = true;
         this.syncValidationClasses();
-        if (!this.isFormNoValidate() && this.required && !this.hasValue()) {
+        const submitter = (event as SubmitEvent).submitter;
+        const submitterNoValidate =
+          (submitter instanceof HTMLButtonElement ||
+            submitter instanceof HTMLInputElement) &&
+          submitter.formNoValidate;
+        if (
+          !this.isFormNoValidate() &&
+          !submitterNoValidate &&
+          this.required &&
+          !this.hasValue()
+        ) {
           event.preventDefault();
           event.stopPropagation();
           return false;

As per coding guidelines, update tests when user-facing behavior changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/components/select/select.tsx` around lines 393 - 400,
Update the formSubmitHandler in the select component to inspect
SubmitEvent.submitter and bypass the required-value prevention when the
submitter’s formNoValidate property is true, while preserving existing
form-level noValidate behavior. Add a component test covering submission of an
empty required select through a formnovalidate submit button or input.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/core/src/components/select/select.tsx`:
- Around line 389-408: Add a consumer-focused changeset documenting the public
ix-select validation and form-submission behavior change, including its
user-facing impact and appropriate release bump. Do not treat this as
internal-only, since the modified connectedCallback behavior affects consumers.
- Around line 393-400: Update the formSubmitHandler in the select component to
inspect SubmitEvent.submitter and bypass the required-value prevention when the
submitter’s formNoValidate property is true, while preserving existing
form-level noValidate behavior. Add a component test covering submission of an
empty required select through a formnovalidate submit button or input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 158668fc-b435-4eb9-a216-9c612a46c669

📥 Commits

Reviewing files that changed from the base of the PR and between 1b16a74 and 0aeccfc.

📒 Files selected for processing (1)
  • packages/core/src/components/select/select.tsx

@nuke-ellington nuke-ellington removed this from the 5.2.0 milestone Aug 6, 2026
@khathija-ahamadi
khathija-ahamadi requested a review from a team as a code owner August 18, 2026 04:33
@sonarqubecloud

Copy link
Copy Markdown

lzeiml
lzeiml previously approved these changes Sep 30, 2026
@flxlst09 flxlst09 added this to the 6.0.0 milestone Nov 4, 2026
@flxlst09 flxlst09 assigned nuke-ellington and unassigned lzeiml Nov 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@nuke-ellington
nuke-ellington merged commit 28053ca into main Nov 11, 2026
25 checks passed
@nuke-ellington
nuke-ellington deleted the feat/2595-input-validation-select branch November 11, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants