Repository navigation
bug: Ion-input is broken with 4.7.x #19084
Copy link
Copy link
Closed
Labels
package: angular@ionic/angular package@ionic/angular packagetype: buga confirmed bug reporta confirmed bug report
Description
Bug Report
Ionic version:
[x] 4.7.x
Current behavior:
Ionic input control not working and refreshing UI as expected
Expected behavior:
Prevent write value on disabled ion-input control and Change detection should refresh the UI
Related code:
<!-- Anticipo a rentas incluido -->
<ion-col size-xs="12" size-lg="4">
<ion-item mode="md" class="item-form-group switch">
<ion-label (click)="anticipoARentasIncluido.setValue(!anticipoARentasIncluido.value)">
Anticipo a rentas incluido
</ion-label>
<ion-toggle formControlName="AnticipoARentasIncluido" (ionChange)="handleAnticipoRentasIncluido($event)"></ion-toggle>
</ion-item>
</ion-col>
<!-- Anticipo a rentas con IVA -->
<ion-col size-xs="12" size-lg="4">
<ion-item mode="md" class="item-form-group" [disabled]="anticipoARentasIncluido.value != true">
<ion-label position="stacked">Anticipo a rentas con IVA</ion-label>
<ion-input #inputAnticipoRentas type="text" inputmode="numeric" maxlength="13"
formControlName="AnticipoARentas" (ionChange)="handleCommissionsPercent($event)"
[brmasker]="{money: true, thousand: ',', decimalCaracter: '.', decimal: '2'}">
<ion-icon name="logo-usd" slot="start" class="money-icon"></ion-icon>
</ion-input>
</ion-item>
<div class="error-container" *ngIf="anticipoARentas.touched == true && anticipoARentas.errors">
<div class="error-message" *ngIf="anticipoARentas.errors['required']">
<ion-icon name="information-circle-outline" aria-label="invalid input"></ion-icon>
<span>Campo obligatorio</span>
</div>
</div>
</ion-col>
handleAnticipoRentasIncluido(event: CustomEvent) {
const value = event.detail['checked'];
if (value == true) {
this.anticipoARentas.setValidators([Validators.required]);
this.anticipoARentas.updateValueAndValidity();
this.changeDetectorRef.detectChanges();
this.anticipoARentas.markAsTouched();
} else {
this.anticipoARentas.clearValidators();
this.anticipoARentas.updateValueAndValidity();
this.changeDetectorRef.detectChanges();
}
}
Ionic info:
Ionic:
Ionic CLI : 5.1.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.7.4
@angular-devkit/build-angular : 0.13.0
@angular-devkit/schematics : 7.2.3
@angular/cli : 7.3.1
@ionic/angular-toolkit : 1.4.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 13 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.7 (update available: 0.2.8)
System:
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v10.16.0 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
package: angular@ionic/angular package@ionic/angular packagetype: buga confirmed bug reporta confirmed bug report

Activity
liamdebeasi commentedon Aug 15, 2019
Thanks for the issue. Are you able to provide a Stackblitz/repo with a reproduction of the issue? I am unable to reproduce this issue on my end. You can use this link as a base Stackblitz: https://stackblitz.com/edit/ionic-v4-angular-tabs
I have provided a Stackblitz of a working ion-input + forms demo here: https://stackblitz.com/edit/ionic-v4-angular-tabs-fmeseo.
Thanks!
eulerchavez commentedon Aug 15, 2019
Hi there,
In this Stackblitz I was able to reproduce all the issues and one more, when I use markAsTouched, the input not display the "red line".
https://stackblitz.com/edit/ionic-v4-angular-tabs-z2mmyk
Thanks 🙏
liamdebeasi commentedon Oct 28, 2019
Apologies for the delay in response. I was able to reproduce this and will look into a fix. As a temporary workaround, you can set the
disabledproperty directly on theion-inputrather than theion-item. Thanks!liamdebeasi commentedon Aug 2, 2022
Hi there,
We are proposing some changes to form components that seek to resolve this issue. We would love your feedback on these proposed changes! You can read more about the changes and leave comments here: #25661
feat(input): component can be used outside of ion-item (#26283)
liamdebeasi commentedon Nov 15, 2022
Thanks for the report. In Ionic 7 we will be introducing a new syntax for using form components such as
ion-input. You can find a summary of the changes here: #25661The reported issue is fixed with this new syntax. Work to update
ion-inputto use this new syntax has been completed, so I am going mark this issue as resolved. We plan to have a public beta period for Ionic 7 in the future. You can visit the Ionic Blog, Ionic Twitter, or our GitHub Releases Page to be notified when the Ionic 7 beta is released. Let me know if you have any questions. Thanks!ionitron-bot commentedon Dec 15, 2022
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.