Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions projects/igniteui-angular/src/lib/directives/button/button-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Output,
booleanAttribute,
inject,
afterRenderEffect,
AfterViewInit,
} from '@angular/core';
import { PlatformUtil } from '../../core/utils';

Expand All @@ -20,8 +20,9 @@ export const IgxBaseButtonType = {


@Directive()
export abstract class IgxButtonBaseDirective {
export abstract class IgxButtonBaseDirective implements AfterViewInit{
private _platformUtil = inject(PlatformUtil);
private _viewInit = false;

/**
* Emitted when the button is clicked.
Expand Down Expand Up @@ -101,15 +102,16 @@ export abstract class IgxButtonBaseDirective {
// In SSR there is no paint, so there’s no visual rendering or transitions to suppress.
// Fix style flickering https://github.com/IgniteUI/igniteui-angular/issues/14759
if (this._platformUtil.isBrowser) {
afterRenderEffect({
write: () => {
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
},
read: () => {
requestAnimationFrame(() => {
this.element.nativeElement.style.removeProperty('--_init-transition');
});
}
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
}
}

public ngAfterViewInit(): void {
if (this._platformUtil.isBrowser && !this._viewInit) {
this._viewInit = true;

requestAnimationFrame(() => {
this.element.nativeElement.style.removeProperty('--_init-transition');
});
}
}
Expand Down
Loading