Skip to content

Commit 1c72c05

Browse files
fix(button): button suffering from FOUC in certain cases (#16403)
* fix(button): button suffering from FOUC in certain cases * fix(ESF): Fixed a test in ESF search component. --------- Co-authored-by: Galina Edinakova <gedinakova@infragistics.com>
1 parent 846922d commit 1c72c05

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

projects/igniteui-angular/src/lib/directives/button/button-base.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Output,
99
booleanAttribute,
1010
inject,
11-
afterRenderEffect,
11+
AfterViewInit,
1212
} from '@angular/core';
1313
import { PlatformUtil } from '../../core/utils';
1414

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

2121

2222
@Directive()
23-
export abstract class IgxButtonBaseDirective {
23+
export abstract class IgxButtonBaseDirective implements AfterViewInit{
2424
private _platformUtil = inject(PlatformUtil);
25+
private _viewInit = false;
2526

2627
/**
2728
* Emitted when the button is clicked.
@@ -101,15 +102,16 @@ export abstract class IgxButtonBaseDirective {
101102
// In SSR there is no paint, so there’s no visual rendering or transitions to suppress.
102103
// Fix style flickering https://github.com/IgniteUI/igniteui-angular/issues/14759
103104
if (this._platformUtil.isBrowser) {
104-
afterRenderEffect({
105-
write: () => {
106-
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
107-
},
108-
read: () => {
109-
requestAnimationFrame(() => {
110-
this.element.nativeElement.style.removeProperty('--_init-transition');
111-
});
112-
}
105+
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
106+
}
107+
}
108+
109+
public ngAfterViewInit(): void {
110+
if (this._platformUtil.isBrowser && !this._viewInit) {
111+
this._viewInit = true;
112+
113+
requestAnimationFrame(() => {
114+
this.element.nativeElement.style.removeProperty('--_init-transition');
113115
});
114116
}
115117
}

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6580,27 +6580,24 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
65806580

65816581
// Scroll the search list to the bottom.
65826582
let scrollbar = GridFunctions.getExcelStyleSearchComponentScrollbar(fix);
6583+
expect(scrollbar.scrollTop).toBe(0);
6584+
let listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
6585+
expect(listItems[0].innerText).toBe('Select All');
6586+
65836587
scrollbar.scrollTop = 3000;
65846588
await wait();
65856589
fix.detectChanges();
6590+
expect(listItems[0].innerText).not.toBe('Select All');
6591+
expect(scrollbar.scrollTop).toBeGreaterThan(300);
65866592

65876593
// Select another column
65886594
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
65896595
await wait();
65906596
fix.detectChanges();
65916597

65926598
// Update scrollbar
6593-
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
65946599
scrollbar = GridFunctions.getExcelStyleSearchComponentScrollbar(fix);
6595-
await wait();
6596-
fix.detectChanges();
6597-
6598-
// Get the display container and its parent and verify that the display container is at start
6599-
const displayContainer = searchComponent.querySelector('igx-display-container');
6600-
const displayContainerRect = displayContainer.getBoundingClientRect();
6601-
const parentContainerRect = displayContainer.parentElement.getBoundingClientRect();
6602-
6603-
expect(displayContainerRect.top - parentContainerRect.top <= 1).toBe(true, 'search scrollbar did not reset');
6600+
expect(scrollbar.scrollTop).toBe(0, 'search scrollbar did not reset');
66046601
});
66056602
});
66066603

0 commit comments

Comments
 (0)