diff --git a/packages/ui-components/src/components/windowedlist.ts b/packages/ui-components/src/components/windowedlist.ts index 7afc8d4a193c..4e7ba3e2126a 100644 --- a/packages/ui-components/src/components/windowedlist.ts +++ b/packages/ui-components/src/components/windowedlist.ts @@ -16,6 +16,7 @@ import { ArrayExt } from '@lumino/algorithm'; import { PromiseDelegate } from '@lumino/coreutils'; import { IDisposable } from '@lumino/disposable'; import { Message, MessageLoop } from '@lumino/messaging'; +import { Throttler } from '@lumino/polling'; import { ISignal, Signal } from '@lumino/signaling'; import { PanelLayout, Widget } from '@lumino/widgets'; @@ -688,6 +689,7 @@ export class WindowedList< this._scrollToItem = null; this._scrollRepaint = null; this._scrollUpdateWasRequested = false; + this._updater = new Throttler(() => this.update(), 50); this._resizeObserver = null; this._viewModel.stateChanged.connect(this.onStateChanged, this); @@ -727,6 +729,14 @@ export class WindowedList< return this._viewModel; } + /** + * Dispose the windowed list. + */ + dispose(): void { + this._updater.dispose(); + super.dispose(); + } + /** * Callback on event. * @@ -884,7 +894,7 @@ export class WindowedList< this.viewModel.height = msg.height >= 0 ? msg.height : this.node.getBoundingClientRect().height; if (this.viewModel.height !== previousHeight) { - this.update(); + void this._updater.invoke(); } super.onResize(msg); } @@ -1118,6 +1128,7 @@ export class WindowedList< private _scrollRepaint: number | null; private _scrollToItem: [number, WindowedList.ScrollToAlign] | null; private _scrollUpdateWasRequested: boolean; + private _updater: Throttler; } /**