Skip to content

Commit 915c8aa

Browse files
committed
Use JupyterLuminoPanelWidget for html manager output widget's lumino widget
Previously the processLuminoMessage was not getting called because Panel did not know to call it. This messed up the message propatation in the html manager output widget, with such affects as the layout widget for the output widget not getting initialized, the displayed event not being triggered, etc. We also take the opportunity to make the JupyterLab output widget use the base JupyterLuminoPanelWidget, rather than having its own copy of the same code. We also incorporate some fixes from the jlab output widget view into the html output widget view. Fixes #3529
1 parent 9c56b1d commit 915c8aa

File tree

4 files changed

+12
-49
lines changed

4 files changed

+12
-49
lines changed

packages/base/src/widget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ export class JupyterLuminoPanelWidget extends Panel {
936936
return;
937937
}
938938
super.dispose();
939-
this._view.remove();
939+
this._view?.remove();
940940
this._view = null!;
941941
}
942942

packages/html-manager/src/output.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as outputBase from '@jupyter-widgets/output';
55

6-
import { Panel } from '@lumino/widgets';
6+
import { JupyterLuminoPanelWidget } from '@jupyter-widgets/base';
77

88
import { OutputAreaModel, OutputArea } from '@jupyterlab/outputarea';
99

@@ -52,7 +52,7 @@ export class OutputModel extends outputBase.OutputModel {
5252

5353
export class OutputView extends outputBase.OutputView {
5454
_createElement(tagName: string): HTMLElement {
55-
this.luminoWidget = new Panel();
55+
this.luminoWidget = new JupyterLuminoPanelWidget({ view: this });
5656
return this.luminoWidget.node;
5757
}
5858

@@ -66,10 +66,9 @@ export class OutputView extends outputBase.OutputView {
6666
}
6767

6868
render(): void {
69-
const manager = this.model.widget_manager;
70-
const rendermime = manager.renderMime;
69+
super.render();
7170
this._outputView = new OutputArea({
72-
rendermime: rendermime,
71+
rendermime: this.model.widget_manager.renderMime,
7372
model: this.model.outputs,
7473
});
7574
this.luminoWidget.insertWidget(0, this._outputView);
@@ -78,7 +77,12 @@ export class OutputView extends outputBase.OutputView {
7877
this.update();
7978
}
8079

80+
remove(): any {
81+
this._outputView.dispose();
82+
return super.remove();
83+
}
84+
8185
model: OutputModel;
8286
private _outputView: OutputArea;
83-
luminoWidget: Panel;
87+
luminoWidget: JupyterLuminoPanelWidget;
8488
}

python/jupyterlab_widgets/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"@lumino/algorithm": "^1.9.1",
6868
"@lumino/coreutils": "^1.11.1",
6969
"@lumino/disposable": "^1.10.1",
70-
"@lumino/messaging": "^1.10.1",
7170
"@lumino/properties": "^1.8.1",
7271
"@lumino/signaling": "^1.10.1",
7372
"@lumino/widgets": "^1.30.0",

python/jupyterlab_widgets/src/output.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
import * as outputBase from '@jupyter-widgets/output';
55

6-
import { DOMWidgetView, JupyterLuminoWidget } from '@jupyter-widgets/base';
7-
8-
import { Message } from '@lumino/messaging';
6+
import { JupyterLuminoPanelWidget } from '@jupyter-widgets/base';
97

108
import { Panel } from '@lumino/widgets';
119

@@ -122,44 +120,6 @@ export class OutputModel extends outputBase.OutputModel {
122120
private _outputs: OutputAreaModel;
123121
}
124122

125-
export class JupyterLuminoPanelWidget extends Panel {
126-
constructor(options: JupyterLuminoWidget.IOptions & Panel.IOptions) {
127-
const view = options.view;
128-
delete (options as any).view;
129-
super(options);
130-
this._view = view;
131-
}
132-
133-
/**
134-
* Process the Lumino message.
135-
*
136-
* Any custom Lumino widget used inside a Jupyter widget should override
137-
* the processMessage function like this.
138-
*/
139-
processMessage(msg: Message): void {
140-
super.processMessage(msg);
141-
this._view.processLuminoMessage(msg);
142-
}
143-
144-
/**
145-
* Dispose the widget.
146-
*
147-
* This causes the view to be destroyed as well with 'remove'
148-
*/
149-
dispose(): void {
150-
if (this.isDisposed) {
151-
return;
152-
}
153-
super.dispose();
154-
if (this._view) {
155-
this._view.remove();
156-
}
157-
this._view = null!;
158-
}
159-
160-
private _view: DOMWidgetView;
161-
}
162-
163123
export class OutputView extends outputBase.OutputView {
164124
_createElement(tagName: string): HTMLElement {
165125
this.luminoWidget = new JupyterLuminoPanelWidget({ view: this });

0 commit comments

Comments
 (0)