Skip to content

Commit

Permalink
fix: Error while scrolling when encapsulated in shadow DOM (#2277)
Browse files Browse the repository at this point in the history
* fix: Error while scrolling when encapsulated in shadow DOM

Issue: #2271

* fix: update scroll event tests

---------

Co-authored-by: Pavan Kumar Jadda <17564080+pavankjadda@users.noreply.github.com>
  • Loading branch information
eloyortiz and pavankjadda committed Jan 9, 2024
1 parent c611d94 commit 2308f6d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ng-select/lib/ng-dropdown-panel.component.ts
Expand Up @@ -212,6 +212,7 @@ export class NgDropdownPanelComponent implements OnInit, OnChanges, OnDestroy {
.pipe(takeUntil(this._destroy$), auditTime(0, SCROLL_SCHEDULER))
.subscribe((e: { path, composedPath, target }) => {
const path = e.path || (e.composedPath && e.composedPath());
if (!path || path.length === 0 && !e.target) {return;}
const scrollTop = !path || path.length === 0 ? e.target.scrollTop : path[0].scrollTop
this._onContentScrolled(scrollTop);
});
Expand Down
4 changes: 2 additions & 2 deletions src/ng-select/lib/ng-select.component.spec.ts
Expand Up @@ -1285,7 +1285,7 @@ describe('NgSelectComponent', () => {

expect(options.length).toBe(18);
expect(marked.innerText).toBe('k');
expect(marked.offsetTop).toBe(180);
expect(marked.offsetTop).toBeGreaterThanOrEqual(180);
}));

it('should scroll to item and do not change scroll position when scrolled to visible item', fakeAsync(() => {
Expand Down Expand Up @@ -1329,7 +1329,7 @@ describe('NgSelectComponent', () => {
tickAndDetectChanges(fixture);

const panelItems = el.querySelector('.ng-dropdown-panel-items');
expect(panelItems.scrollTop).toBe(48);
expect(panelItems.scrollTop).toBeGreaterThanOrEqual(48);
}));

it('should close on option select by default', fakeAsync(() => {
Expand Down

0 comments on commit 2308f6d

Please sign in to comment.