Skip to content

Commit c8c5c94

Browse files
committed
Handle the resize event of the cell output widget
1 parent 7f7881a commit c8c5c94

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

packages/base/src/widget.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DocumentWidget } from '@jupyterlab/docregistry';
44
import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
55
import { JSONValue } from '@lumino/coreutils';
66
import { ISignal, Signal } from '@lumino/signaling';
7-
import { SplitPanel } from '@lumino/widgets';
7+
import { SplitPanel, Widget } from '@lumino/widgets';
88
import {
99
IJupyterGISModel,
1010
IJupyterGISWidgetContext,
@@ -15,6 +15,9 @@ import {
1515
import { JupyterGISMainViewPanel } from './mainview';
1616
import { MainViewModel } from './mainview/mainviewmodel';
1717
import { ConsoleView } from './console';
18+
import { MessageLoop } from '@lumino/messaging';
19+
20+
const CELL_OUTPUT_WIDGET_CLASS = 'jgis-cell-output-widget';
1821

1922
export class JupyterGISWidget
2023
extends DocumentWidget<JupyterGISPanel, IJupyterGISModel>
@@ -49,7 +52,17 @@ export class JupyterGISOutputWidget
4952
{
5053
constructor(options: JupyterGISOutputWidget.IOptions) {
5154
super(options);
55+
this.addClass(CELL_OUTPUT_WIDGET_CLASS);
5256
this.context = options.context;
57+
58+
const resizeObserver = new ResizeObserver(() => {
59+
// Send a resize message to the widget, to update the child size.
60+
MessageLoop.sendMessage(
61+
this,
62+
Widget.ResizeMessage.UnknownSize
63+
);
64+
});
65+
resizeObserver.observe(this.node);
5366
}
5467

5568
readonly context: IJupyterGISWidgetContext;

python/jupytergis_lab/src/notebookrenderer.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ export class YJupyterGISLuminoWidget extends Panel {
7474
return this._jgisWidget;
7575
}
7676

77-
onResize = (): void => {
78-
if (this._jgisWidget) {
79-
MessageLoop.sendMessage(
80-
this._jgisWidget,
81-
Widget.ResizeMessage.UnknownSize
82-
);
83-
}
84-
};
85-
8677
private _jgisWidget: JupyterGISOutputWidget;
8778
}
8879

0 commit comments

Comments
 (0)