Skip to content

Commit

Permalink
Work for surveyjs/survey-creator#4484 - memory leaks in survey creato…
Browse files Browse the repository at this point in the history
…r - reset list container element ref
  • Loading branch information
tsv2013 committed Aug 29, 2023
1 parent 5476b19 commit f664775
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/knockout/components/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ ko.components.register("sv-list", {
model.initListContainerHtmlElement(componentInfo.element);
return {
model: model,
dispose: () => { _implementor.dispose(); },
dispose: () => {
_implementor.dispose();
model.initListContainerHtmlElement(undefined as any);
},
afterItemRender: (_: any, action: Action) => {
!!ko.tasks && ko.tasks.runEarly();
model.onLastItemRended(action);
Expand Down
6 changes: 6 additions & 0 deletions src/react/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export class List extends SurveyElementBase<IListProps, any> {
this.model.initListContainerHtmlElement(this.listContainerRef.current);
}
}
componentWillUnmount(): void {
super.componentWillUnmount();
if(!!this.model) {
this.model.initListContainerHtmlElement(undefined as any);
}
}
renderElement() {
return (
<div className={this.model.cssClasses.root} ref={this.listContainerRef}>
Expand Down

0 comments on commit f664775

Please sign in to comment.