Skip to content
Open
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions packages/primeng/src/treeselect/treeselect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,31 @@ describe('TreeSelect', () => {
expect(treeSelectInstance.virtualScrollItemSize).toBe(32);
});

it('should pass scrollHeight to tree when virtual scrolling is enabled', async () => {
testComponent.options = Array.from({ length: 50 }, (_, i) => ({
key: i.toString(),
label: `Node ${i}`,
data: `Data ${i}`
}));
testComponent.scrollHeight = '180px';
testComponent.virtualScroll = true;
testComponent.virtualScrollItemSize = 32;
testFixture.changeDetectorRef.markForCheck();
await testFixture.whenStable();
testFixture.detectChanges();

const treeSelectInstance = testFixture.debugElement.query(By.directive(TreeSelect)).componentInstance;
const dropdown = testFixture.debugElement.query(By.css('.p-treeselect-dropdown'));
dropdown.nativeElement.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
await testFixture.whenStable();
testFixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve));
await testFixture.whenStable();
testFixture.detectChanges();
Comment on lines +1346 to +1353

expect(treeSelectInstance.treeViewChild?.scrollHeight).toBe('180px');
});

it('should handle dynamic option updates', async () => {
// Start with empty options
testComponent.options = [];
Expand Down
1 change: 1 addition & 0 deletions packages/primeng/src/treeselect/treeselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const TREESELECT_INSTANCE = new InjectionToken<TreeSelect>('TREESELECT_INSTANCE'
[filterPlaceholder]="filterPlaceholder"
[filterLocale]="filterLocale"
[filteredNodes]="filteredNodes"
[scrollHeight]="virtualScroll ? scrollHeight : undefined"
[virtualScroll]="virtualScroll"
[virtualScrollItemSize]="virtualScrollItemSize"
[virtualScrollOptions]="virtualScrollOptions"
Expand Down