Skip to content

Commit d323be1

Browse files
authored
Remove any existing views after displaying a new one (#28)
1 parent 564dddf commit d323be1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ipyshiny/static/output.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/output.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ class IPyWidgetOutput extends Shiny.OutputBinding {
4747
}
4848
model.then((m) => {
4949
const view = manager.create_view(m, {});
50-
view.then((v) => manager.display_view(v, {el: el}));
50+
view.then(v => {
51+
manager.display_view(v, {el: el}).then(() => {
52+
// TODO: This is not an ideal way to handle the case where another render
53+
// is requested before the last one is finished displaying the view, but
54+
// it's probably the least unobtrusive way to handle this for now
55+
//
56+
while (el.childNodes.length > 1) {
57+
el.removeChild(el.childNodes[0]);
58+
}
59+
})
60+
});
5161
});
5262
}
5363
}

0 commit comments

Comments
 (0)