ionic-team / ionic-team/ionic-framework

feat(angular): support markAsTouched() for angular signal forms

Offen
#31,405 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
triage
Vorherrschende Sprache
TypeScript
Sterne
52.7k
Forks
13.3k
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
51

Beschreibung

### Prerequisites

- [x] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [x] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [x] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.

### Describe the Feature Request

I already took a look at https://github.com/ionic-team/ionic-framework/issues/30805 and I think Ionic currently doesn't support the `markAsTouched()` use case despite the opposite being stated.

Blurring out of a signal form field after focusing it correctly mark the field with the `ion-touched` class.

But calling `markAsTouched()` on a signal form doesn't work.

### Describe the Use Case

I have a signal form like this:

```html


Submit

```

```ts
export class AppComponent {
protected readonly form = form(signal({ field: '' }));
protected onSubmit(): void {
this.form().markAsTouched();
}
}
```

When clicking on the submit button (without focusing/blurring the input) the `ng-touched` class is correctly applied but I still have `ion-untouched` instead of `ion-touched`.

### Describe Preferred Solution

The `ion-touched` class should be automatically added to the ion-input, like it does when using `[formControl]` instead of `[formField]`.

### Describe Alternatives

I'm currently fixing the problem by applying the class myself:

```html

```

### Related Code

_No response_

### Additional Information

My app config `providers` includes `provideSignalFormsConfig({ classes: NG_STATUS_CLASSES })` so that the `ng-invalid`, `ng-touched`, and other angular classes are automatically added by Angular, otherwise, `[formField]` no longer have `ng-*` classes applied by default like they used to have with `[formControl]`

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the Angular signal forms integration points used by formRoot, formField, and ion-input, then reproduce the submit example where form().markAsTouched() is called without focusing the field. Done means markAsTouched() causes ion-input to receive ion-touched rather than ion-untouched, while the existing formControl behavior remains intact.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.