Skip to content

bug: Ion-input is broken with 4.7.x #19084

Closed

Description

@eulerchavez

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

Grabación de pantalla 2019-08-13 a las 11 50 38

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

Activity

  1. liamdebeasi commented on Aug 15, 2019

    @liamdebeasi
    Contributor

    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!

  2. eulerchavez commented on Aug 15, 2019

    @eulerchavez
    Author

    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!

    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 🙏

  3. added and removed
    needs: replythe issue needs a response from the user
    on Aug 15, 2019
  4. liamdebeasi commented on Oct 28, 2019

    @liamdebeasi
    Contributor

    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 disabled property directly on the ion-input rather than the ion-item. Thanks!

  5. liamdebeasi commented on Aug 2, 2022

    @liamdebeasi
    Contributor

    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

  6. added
    type: buga confirmed bug report
    and removed
    type: buga confirmed bug report
    on Nov 14, 2022
  7. added a commit that references this issue on Nov 15, 2022
    44472ae
  8. liamdebeasi commented on Nov 15, 2022

    @liamdebeasi
    Contributor

    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: #25661

    The reported issue is fixed with this new syntax. Work to update ion-input to 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!

  9. ionitron-bot commented on Dec 15, 2022

    @ionitron-bot

    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.

  10. locked and limited conversation to collaborators on Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions