Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button loading directive has conflict with disabled directive #207

Open
ChrTall opened this issue Apr 21, 2023 · 4 comments
Open

Button loading directive has conflict with disabled directive #207

ChrTall opened this issue Apr 21, 2023 · 4 comments
Labels
area: button Issues about button discussion Discussion for the project

Comments

@ChrTall
Copy link

ChrTall commented Apr 21, 2023

I would like to use the [loading] directive, while the api loads data, for a button.
This works like described in the docs, but I have the problem that I also want to conditionally set the [disabled] directive on the button, which seems to have no effect.
The button is used with the [matMenuTriggerFor] directive to display a MatMenu.

@nzbin nzbin added question Further information is requested area: button Issues about button labels Apr 22, 2023
@nzbin
Copy link
Member

nzbin commented Apr 22, 2023

Can you give an online example? I want to know how you use it.

@nzbin nzbin closed this as completed Dec 9, 2023
@bonfantefilippo
Copy link

@nzbin Hi! Is this issue closed since it's fixed or not?
I faced the same issue by combining the [disabled]="formGroup.invalid" and [loading]="isLoadingSave"

<button
            type="button"
            mat-flat-button
            [disabled]="myForm.invalid"
            [loading]="isLoadingSave"
            color="primary"
            (click)="saveForm()">
            {{ t('BUTTONS.save') }}
</button>

On saveForm, the flag isLoadingSave is set to false when an API completes and also the form is reset to its initial state.
If I remove the loading attribute, the button correctly disable, but with disabled and loading together not.

Lib version used: 16.1.3

@miroslavgrozdanovski
Copy link

@nzbin, we've just encountered the same issue. Looking at the source code, this issue happens because whenever the loading input flag is changed back to false, the disabled attribute is always removed, not taking into consideration that we may only want to stop the loader, but keep the button disabled.

@nzbin nzbin reopened this Jul 1, 2024
@nzbin nzbin added discussion Discussion for the project and removed question Further information is requested labels Jul 1, 2024
@nzbin
Copy link
Member

nzbin commented Jul 26, 2024

@nzbin Hi! Is this issue closed since it's fixed or not? I faced the same issue by combining the [disabled]="formGroup.invalid" and [loading]="isLoadingSave"

<button
            type="button"
            mat-flat-button
            [disabled]="myForm.invalid"
            [loading]="isLoadingSave"
            color="primary"
            (click)="saveForm()">
            {{ t('BUTTONS.save') }}
</button>

On saveForm, the flag isLoadingSave is set to false when an API completes and also the form is reset to its initial state. If I remove the loading attribute, the button correctly disable, but with disabled and loading together not.

Lib version used: 16.1.3

Can you give me an online example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: button Issues about button discussion Discussion for the project
Projects
None yet
Development

No branches or pull requests

4 participants