Skip to content

[Ionic 4] Disabled button not enabled when property changes  #17193

Closed

Description

@rodrigojrmartinez

Bug Report

Ionic version:

[x] 4.x

Current behavior:

It seems to be a bug over the ion-button whenever the disable property changes. This seems to be happening only when you have a ion-button that you mark as disabled based on a property on your component and this ion-button is inside a ion-buttons component (if the ion-button is not wrapped up inside ion-buttons then it works just fine). Once the button is disabled it remains this way… under the hood the action gets triggered because the button is actually enabled but the style of the button remains as disabled. I’ve review the generated html and css classes and once the button is enabled there’s no reference to the ‘button-disabled’ class.

Another thing is that from enabled to disabled it works, you can see the difference. from disabled to enabled is the problem. By triggering detectChanges whenever you switch from disable state doesn’t work either

Expected behavior:

The button should reflect the style of the disabled property in the correct way. Showing it enabled when enabled and disabled on the other case

Steps to reproduce:

Set a button with a disabled property attached to an angular component property, switch the property from true to false and see the changes are not reflected once the button gets disabled, it reamins this way

Related code:

View:

       <ion-button (click)="change()">
            CHANGE
        </ion-button>
        <ion-buttons slot="primary">
            <ion-button [disabled]="disabled" (click)="action()">
                <ion-icon name="home"></ion-icon>
            </ion-button>
        </ion-buttons>

Component:

  public disabled = false;

  public action() {
    console.log('action triggered');
  }

  public change() {
    this.disabled = !this.disabled;
  }

Activity

  1. ionitron-bot commented on Feb 21, 2019

    @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.

  2. locked and limited conversation to collaborators on Feb 21, 2019
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

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions