Skip to content

Commit

Permalink
add disposable listener
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Jan 10, 2025
1 parent babc379 commit b36b37f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vs/base/browser/ui/list/listView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,18 +469,18 @@ export class ListView<T> implements IListView<T> {
}

private _setupFocusObserver(container: HTMLElement): void {
container.addEventListener('focus', () => {
this.disposables.add(addDisposableListener(container, 'focus', () => {
const element = getActiveElement() as HTMLElement | null;
if (this.activeElement !== element && element !== null) {
this.activeElement = element;
this._scrollToActiveElement(this.activeElement, container);
}
}, true);
}, true));
}

private _scrollToActiveElement(element: HTMLElement, container: HTMLElement) {
// The scroll event on the list only fires when scrolling down.
// If the active element is above the viewport, we need to scroll up.
// If the active element is above the viewport, we need to scroll up.
const containerRect = container.getBoundingClientRect();
const elementRect = element.getBoundingClientRect();

Expand Down

0 comments on commit b36b37f

Please sign in to comment.