Skip to content

Validations for select component.#2510

Open
khathija-ahamadi wants to merge 6 commits into
mainfrom
feat/2595-input-validation-select
Open

Validations for select component.#2510
khathija-ahamadi wants to merge 6 commits into
mainfrom
feat/2595-input-validation-select

Conversation

@khathija-ahamadi
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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: 88b9e1f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Copy Markdown
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 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.

Comment thread packages/core/src/components/select/select.tsx Outdated
Comment thread packages/core/src/components/select/select.tsx
Comment thread packages/core/src/components/select/select.tsx
Comment thread packages/core/src/components/select/select.tsx Outdated
@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
if (this.required && !this.hasValue()) {
event.preventDefault();
event.stopPropagation();
this.hostElement.focus();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Calling focus here introduces potential UX issues if there is more than one invalid element during form submission. Also in invalid listener in l377

await expect(select).toHaveClass(/ix-invalid--required/);

const tabIndex = await select.getAttribute('tabindex');
expect(tabIndex).toBe('0');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we check tab index here?

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.

2 participants