Skip to content

Commit

Permalink
Merge pull request #242 from maartenbreddels/fix_new_vue_app_when_wid…
Browse files Browse the repository at this point in the history
…get_child

fix: create new app when vuetify view is child of a widget for nodeps (Solara and Voila)
  • Loading branch information
mariobuikhuizen authored Apr 3, 2023
2 parents 4a6100c + 0d95d7c commit e43d14f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions js/src/nodepsVuetifyView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
import { DOMWidgetView } from "@jupyter-widgets/base";
import { vueRender, createViewContext } from "jupyter-vue";
import vuetify from "./plugins/nodepsVuetify";

export class VuetifyView extends DOMWidgetView {
remove() {
if (this.vueApp) {
this.vueApp.$destroy();
}
return super.remove();
}

render() {
super.render();
this.displayed.then(() => {
const vueEl = document.createElement("div");
this.el.appendChild(vueEl);
const view = this;

this.vueApp = new Vue({
vuetify,
el: vueEl,
provide: {
viewCtx: createViewContext(this),
},
render(createElement) {
// see VuetifyView.js
if (!view.ipyvuetifyApp) {
view.ipyvuetifyApp = createElement("v-app", [
vueRender(createElement, view.model, view),
]);
}
return view.ipyvuetifyApp;
},
});
});
}

vueRender(createElement) {
return createElement({
provide: {
Expand Down
2 changes: 1 addition & 1 deletion js/src/plugins/nodepsVuetify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* until all users have upgraded to Voila-vuetify > 0.2.2 and voila-embed > 2020-02-11, or
* ipyvuetify bumps a major version */
const vuetify = window.app &&
window.app.$vuetify && { framework: window.app.$vuetify };
window.app.$vuetify && window.app.$options.vuetify;

export default vuetify;

0 comments on commit e43d14f

Please sign in to comment.