question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: form validation should not show red highlight until user has modified the field

See original GitHub issue

Bug Report

Ionic version:

[ ] 4.x [x] 5.x

Current behavior:

In reactive Angular forms, the ion-items within an ion-input, the highlights are marked in red when they have not yet been touched.

Expected behavior:

They should be blue until they are not touched, even though the validation of required giving an error.

Steps to reproduce:

Create a reactive form group and add the required validation

Related code:

import { ReactiveFormsModule } from '@angular/forms';
imports: [
    ReactiveFormsModule,
    ...
],
formGroup: FormGroup;

constructor(public formBuilder: FormBuilder) {
    this.formGroup = this.formBuilder.group({
      text: [
        "",
        [Validators.required]
      ]
    });
}
<form [formGroup]="formGroup">
	<ion-item>
		<ion-label floating>Text</ion-label>
		<ion-input type="text" formControlName="text"></ion-input>
	</ion-item>
</form>

Ionic info:

Ionic:

   Ionic CLI                     : 6.10.1
   Ionic Framework               : @ionic/angular 5.2.2
   @angular-devkit/build-angular : 0.1000.0
   @angular-devkit/schematics    : 8.3.25
   @angular/cli                  : 10.0.0
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 2.2.0
   @capacitor/core : 2.2.0

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v14.3.0
   npm    : 6.14.5
   OS     : Windows 10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
liamdebeasicommented, Jul 14, 2020

Thanks! That makes sense. I agree that this UX can be improved.

Our inputs should align more closely with this example: https://v7.material.angular.io/components/form-field/overview#error-messages. Specifically, the input should be highlighted blue when the user is initially editing the input, and then it should be red when the input is blurred and the validation fails.

0reactions
ntorreycommented, Nov 27, 2022

Is there a workaround to use while we wait for this to be updated?

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: form validation should not show red highlight until ...
In reactive Angular forms, the ion-items within an ion-input, the highlights are marked in red when they have not yet been touched. Expected ......
Read more >
Show red border for all invalid fields after submitting form ...
My question is after clicking on submit button i have to show red border for all the invalid fields. This is my form:...
Read more >
Client-side form validation - Learn web development | MDN
When this attribute is set, the element matches the :required UI pseudo-class and the form won't submit, displaying an error message on ...
Read more >
JavaScript: HTML Form - checking for non empty field
Often, situations arise when a user should fill a single or more than one field in an HTML form before they submit it....
Read more >
Angular Reactive Forms: trigger validation on submit
We also do not display any validation error message. So the user have to guess that something is missing before the submit button...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found