-
Notifications
You must be signed in to change notification settings - Fork 75
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9db50b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
There was a problem hiding this 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.
Let me check, maybe we can implement it that way. |
|
There was a problem hiding this 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!
}) | ||
export class TestInputFormRequired { | ||
public form = new FormGroup({ | ||
name: new FormControl('', Validators.compose([Validators.required])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: new FormControl('', Validators.compose([Validators.required])), | |
name: new FormControl('', Validators.required), |
helperText="Write down your name" | ||
invalidText="Value is required" | ||
formControlName="name" | ||
required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need required since we have the Angular Validator set. One thing I noticed is that we could set the "required"-star on the label based on the ix-required class.
<ix-input | ||
label="Name:" | ||
helperText="Write down your name" | ||
invalidText="Value is required" | ||
formControlName="name" | ||
required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need required since we have the Angular Validator set.
selector: 'test-input-form-with-validators', | ||
template: ` | ||
<form [formGroup]="form"> | ||
<ix-input formControlName="name" [required]="true"> </ix-input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ix-input formControlName="name" [required]="true"> </ix-input> | |
<ix-input formControlName="name"> </ix-input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need required since we have the Angular Validator set.
💡 What is the current behavior?
GitHub Issue Number: Fixes #1680 #1638
🆕 What is the new behavior?
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):
pnpm run docs
)pnpm test
)pnpm lint
)pnpm build
, changes pushed)👨💻 Help & support