Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
perf(autocomplete): Fixes an issue when toggling multiple times a sub…
Browse files Browse the repository at this point in the history
…scription is not cleaned up.
  • Loading branch information
thomaspink committed Feb 4, 2020
1 parent ef0ec3b commit 0b569f6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions components/autocomplete/src/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ export class DtAutocompleteTrigger<T>
);
});
}

if (this._viewportResizer) {
this._viewportSubscription = this._viewportResizer
.change()
.subscribe(() => {
if (this.panelOpen && this._overlayRef) {
this._overlayRef.updateSize({ maxWidth: this._getPanelWidth() });
}
});
}
}

ngOnDestroy(): void {
Expand Down Expand Up @@ -420,16 +430,6 @@ export class DtAutocompleteTrigger<T>
this._closeKeyEventStream.next();
}
});

if (this._viewportResizer) {
this._viewportSubscription = this._viewportResizer
.change()
.subscribe(() => {
if (this.panelOpen && this._overlayRef) {
this._overlayRef.updateSize({ maxWidth: this._getPanelWidth() });
}
});
}
} else {
// Update the panel width and position in case anything has changed.
this._overlayRef.updateSize({ maxWidth: this._getPanelWidth() });
Expand Down

0 comments on commit 0b569f6

Please sign in to comment.