Skip to content

Commit

Permalink
fix(dropdown): prevent unnecessary macrotasks (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and GitHub Enterprise committed Nov 18, 2024
1 parent 614661b commit 7cec758
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions projects/ng-aquila/src/dropdown/dropdown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,8 @@ describe('NxDropdownComponent', () => {

it('should scroll the selected item in the middle of the panel on dropdown change', fakeAsync(() => {
createTestComponent(ScrollingTestComponent);
trigger.click();
tick(500);
flush();
fixture.detectChanges();
tick(1);
openDropdownByClick();

// 4 * 44 + 22 (half of item height) + 12 (firstItemPaddingTop) - 100 (middle of panel)
expect(dropdownInstance.panelBody?.nativeElement.scrollTop).toBe(110);
}));
Expand Down
2 changes: 1 addition & 1 deletion projects/ng-aquila/src/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ export class NxDropdownComponent
// defer it for the next cycle to not run in changed after checked errors
// the combination of dropdown-item notifying parent and when the parent
// tries to fetch the triggerValue from the child throws these errors
setTimeout(() => {
Promise.resolve().then(() => {
if (this._panelOpen) {
this._initActiveItem();
}
Expand Down

0 comments on commit 7cec758

Please sign in to comment.