Closed matheuskt closed 4 years ago
Yes it seems like the issue can be reproduced if you do sort of a long press / click on the button. Then I am able to confuse the component to show activated false state when in fact it should be active. https://stackblitz.com/edit/ionic-4-template-y9ypf3
So in the above stackblitz I can "mousedown" on the FAB and wait 2 secs until I release mouse button (mouseup). This way I can get it into confusing state. If I keep doing perfect click (mousedown/mouseup) I think it works as intended.
Haven't updated it in a while, but came back to work on the project that has this issue and it probably has something to do with Angular change detection.
A simple workaround for this is to use the ChangeDetectorRef's detectChanges()
method.
home.page.html
<div *ngIf="fab.activated" class="fab-backdrop"></div>
<ion-fab (click)="detectChanges()" #fab vertical="bottom" horizontal="end" slot="fixed">
home.page.ts
constructor(private _changeRef: ChangeDetectorRef) { }
detectChanges() {
setTimeout(() => {
this._changeRef.detectChanges();
});
}
For another strange reason setTimeout()
is necessary here or it wont work properly.
Is there any update on this?
Same problem here
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.
Can't use IonFab's activated property in conditions on template
Ionic version:
[x] 4.x
Current behavior:
GIF: https://im2.ezgif.com/tmp/ezgif-2-7ec13650fe23.gif
When trying to use the IonFab's / IonFabList's activated property as a condition to any element on the template it doesn't update as expected.
The property actually updates to true/false but the template acts strangely.
Expected behavior:
When clicking on a Fab Button the activated property updates to the current state and the templates condition updates accordingly.
Steps to reproduce:
1) Create a new Ionic 4.x application. 2) Create a Fab Container with a FabButton and a FabList with buttons inside it. And use ViewChild to get a reference from the FabContainer. 4) Use the Fab container activated property as a render condition to any element on the template.
Related code:
Sample repository: https://github.com/matheuskt/ionic-fab-issue
home.page.ts
home.page.html
Other information:
Ionic info: