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

Input is not marked as invalid #14854

Open
wnvko opened this issue Oct 1, 2024 · 3 comments
Open

Input is not marked as invalid #14854

wnvko opened this issue Oct 1, 2024 · 3 comments
Assignees
Labels

Comments

@wnvko
Copy link
Contributor

wnvko commented Oct 1, 2024

Description

Describe the issue.

  • igniteui-angular version: ~18.1.0
  • browser: all

Steps to reproduce

Create reactive form like this:

export interface MyClass{
  name: FormControl<string | null>,
}
public myForm: FormGroup<MyClass>;
constructor(
    private aBNorthwindService: ABNorthwindService,
) {
    this.myForm = new FormGroup<MyClass>({
      name: new FormControl<string | null>('', Validators.required),
   });
}
<form [formGroup]="myForm">
    <igx-input-group type="border">
      <input type="text" formControlName="name" igxInput />
      <label igxLabel>Name</label>
    </igx-input-group>
</form>

Run the application. Click in the input and click outside the input.

Result

Input does not paint in red - it is not invalidated.

Expected result

Input should be painted in red showing it is invalid.

Note

On second click the input paints in red and is correctly shown as invalid. Also, if the input is not part of reactive form binding it is working correctly.

@wnvko wnvko added 🐛 bug Any issue that describes a bug 🆕 status: new labels Oct 1, 2024
@hanastasov hanastasov changed the title Input does not marked as invalid Input is not marked as invalid Oct 1, 2024
@jackofdiamond5 jackofdiamond5 added 👀 status: in-review Issue is currently being reviewed input-group input 🛠️ status: in-development Issues and PRs with active development on them status: not-to-fix and removed 🆕 status: new 👀 status: in-review Issue is currently being reviewed 🛠️ status: in-development Issues and PRs with active development on them labels Oct 3, 2024
@jackofdiamond5
Copy link
Member

Since the outlined problem here comes from the CG - the problem is not with the input directive but with the generation. The current generation outputs this for NGM:
image

And this for SA:
image

It seems to me that because Angular will attempt to resolve the imports in order of occurrence, if the IgxInputGroupModule / IGX_INPUT_GROUP_DIRECTIVES is placed before the FormsModule / ReactiveFormsModule then they will get resolved first and they will not have access to the fully resolved FormsModule & ReactiveFormsModule. Even though later the latter get resolved this still to messes up the NgControl as it is initially incapable of updating its touched state, which in turn causes the problem outlined in the issue.

The fix here is rather straightforward - always import the FormsModule & ReactiveFormsModule before any of our components, modules or directives.

@pmoleri
Copy link

pmoleri commented Oct 8, 2024

@jackofdiamond5
I'm not convinced about this part "Angular will attempt to resolve the imports in order of occurrence".

The workaround is useful but I think that we should dig more to understand the actual cause of the issue and see if we can prevent it in the first place.

@pmoleri pmoleri reopened this Oct 8, 2024
Copy link

github-actions bot commented Dec 8, 2024

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Dec 8, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2024
@wnvko wnvko reopened this Dec 15, 2024
@github-actions github-actions bot removed the status: inactive Used to stale issues and pull requests label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants