Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: avoid internal validation before interacting with input #1682

Merged
merged 17 commits into from
Feb 18, 2025

Conversation

danielleroux
Copy link
Collaborator

@danielleroux danielleroux commented Feb 7, 2025

💡 What is the current behavior?

GitHub Issue Number: Fixes #1680 #1638

🆕 What is the new behavior?

  • Stop validate required if never interacted with input
  • Add flag to value accessor to prevent default classmapping between ng- and ix- classes
<form
  class="form-validation-example"
  [formGroup]="exampleForm"
  (ngSubmit)="submit()"
>
  <ix-input
    label="Name:"
    helperText="Write down your name"
    invalidText="Value is required"
    formControlName="name"
    [suppressClassMapping]="true"
    [class.ix-invalid]="!exampleForm.get('name')!.valid && exampleForm.get('name')!.touched"
    required
  >
  </ix-input>
  <ix-button type="submit" [disabled]="!exampleForm.valid">Submit</ix-button>
</form>
  • value-accessor ignores an invalid NgControl if it has a required validation which shows and display and the control is never touched.

🏁 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
  • 📄 Documentation was reviewed/updated (pnpm run 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

Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: b32e69b

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

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

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

@danielleroux danielleroux marked this pull request as ready for review February 11, 2025 15:56
Copy link
Collaborator

@jul-lam jul-lam left a comment

Choose a reason for hiding this comment

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

Jsut a minor unimportant thing: maybe we could also add a textarea story.

One thing I was thinking about while reviewing is that we could also do something similar like angular does, setting the ix-invalid--required regardless, but applying the css only if also ix-touched is present. We could also do this over our ValueAccessor in angular, where we only apply the mapping of ix-invalid--required if ng-invalid and ng-touched is present.

@danielleroux danielleroux requested a review from jul-lam February 12, 2025 16:35
jul-lam
jul-lam previously approved these changes Feb 13, 2025
@danielleroux
Copy link
Collaborator Author

Jsut a minor unimportant thing: maybe we could also add a textarea story.

One thing I was thinking about while reviewing is that we could also do something similar like angular does, setting the ix-invalid--required regardless, but applying the css only if also ix-touched is present. We could also do this over our ValueAccessor in angular, where we only apply the mapping of ix-invalid--required if ng-invalid and ng-touched is present.

Let me check, maybe we can implement it that way.

@danielleroux danielleroux marked this pull request as draft February 13, 2025 07:44
@danielleroux danielleroux marked this pull request as ready for review February 13, 2025 13:54
@danielleroux danielleroux requested a review from jul-lam February 13, 2025 13:55
Copy link
Collaborator

@jul-lam jul-lam left a comment

Choose a reason for hiding this comment

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

I really like the solution now!

…d.ts

Co-authored-by: Julian Lamplmair <151610373+jul-lam@users.noreply.github.com>
@danielleroux danielleroux requested a review from jul-lam February 17, 2025 07:16
jul-lam
jul-lam previously approved these changes Feb 17, 2025
@danielleroux danielleroux requested a review from jul-lam February 17, 2025 12:50
jul-lam
jul-lam previously approved these changes Feb 17, 2025
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@danielleroux danielleroux merged commit f41b5d6 into main Feb 18, 2025
15 checks passed
@danielleroux danielleroux deleted the fix/inital-input-behaviour branch February 18, 2025 10:41
This was referenced Feb 18, 2025
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.

Form Fields Display as Invalid Without User Interaction
3 participants