Skip to content

Commit

Permalink
Fix initial wrong state of a field being not touched when it is touched.
Browse files Browse the repository at this point in the history
  • Loading branch information
Exitare committed Jan 25, 2025
1 parent 8febd6f commit 78899c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<label class="control-label" for="minlevel">minlevel</label>
<i class="fas fa-info-circle ms-1" placement="auto" [tooltip]="'CREATURE.TEMPLATE.MIN_MAX_LEVEL' | translate"></i>
<input [formControlName]="'minlevel'" id="minlevel" type="number" class="form-control form-control-sm" />
<input keiraInputValidation [formControlName]="'minlevel'" id="minlevel" type="number" class="form-control form-control-sm" />
</div>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<label for="maxLevel">maxlevel</label>
Expand Down
3 changes: 2 additions & 1 deletion libs/shared/directives/src/validate-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class InputValidationDirective extends SubscriptionHandler implements OnI

this.subscriptions.push(
control.statusChanges?.subscribe(() => {
console.log('control', control);
this.updateErrorMessage(control);
}),
);
Expand All @@ -34,6 +33,8 @@ export class InputValidationDirective extends SubscriptionHandler implements OnI
this.errorDiv = null;
}

if (control?.invalid) control?.markAsTouched();

if (control?.touched && control?.invalid) {
console.log('control.errors', control.errors);
this.errorDiv = this.renderer.createElement('div');
Expand Down

0 comments on commit 78899c7

Please sign in to comment.