oblique-bit / oblique

An Angular front-end framework Tailored for your swiss branded business web application, Oblique provides a standardized corporate design look and feel as well as a collection of ready-to-use Angular components. Oblique, through its fully customizable master layout, takes care of the application's structure, letting you focus on the content.
https://oblique.bit.admin.ch
MIT License
55 stars 13 forks source link

Checkbox blink at first click when observables are used. #115

Closed ice-blaze closed 8 months ago

ice-blaze commented 1 year ago

Hello,

I use the mat-checkbox in my project and in one situation I got a blinking case.

Html

<mat-checkbox
  [checked]="checked$ | async"
  [indeterminate]="indeterminate$ | async"
  >a checkbox</mat-checkbox
>
<hr />
<button mat-button obButton="primary" (click)="indeterminateClick()">
  toggle indeterminate
</button>

The component

export class HomeComponent {
  private _checked = true;
  public checked$ = new Subject<boolean>();
  private _indeterminate = false;
  public indeterminate$ = new Subject<boolean>();

  public constructor(private readonly changeDetector: ChangeDetectorRef) {}

  public ngAfterViewInit(): void {
    this.checked$.next(this._checked);
    this.indeterminate$.next(this._indeterminate);
    this.changeDetector.detectChanges();
  }

  public checkedClick(): void {
    this._checked = !this._checked;
    this.checked$.next(this._checked);
  }

  public indeterminateClick(): void {
    this._indeterminate = !this._indeterminate;
    this.indeterminate$.next(this._indeterminate);
  }
}

More details:

Here a stackblitz with the project https://stackblitz.com/edit/stackblitz-starters-1uwfi3?file=angular15-oblique10%2Fsrc%2Fapp%2Fhome%2Fhome.component.ts

Reproduce steps:

Expected behaviour: The checkbox should not blink. It should behave the same way when after the first click on the button we continue to click multiple times, then the animation looks correct.

nina-egger commented 1 year ago

Hello!

Thank you for the report. I created a ticket for this issue. The ticket number in our system is OUI-2551.

Kind Regards

nina-egger commented 8 months ago

Hello @ice-blaze ! I can no longer reproduce this v11 Stackblitz: https://stackblitz.com/edit/oblique-master-layout-example-x9bnnf?file=src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fhome%2Fhome.component.html

Is it okay if I close this issue?

ice-blaze commented 8 months ago

It works fine now indeed. Thanks :)