Skip to content

Commit 4454b10

Browse files
authored
Merge pull request #1061 from jasongrout/boxresize
Send resize message for initial box children.
2 parents 413bb8e + 996005c commit 4454b10

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

jupyter-js-widgets/src/widget_box.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from 'phosphor/lib/algorithm/searching';
1515

1616
import {
17-
sendMessage, Message
17+
postMessage, Message
1818
} from 'phosphor/lib/core/messaging';
1919

2020
import {
@@ -235,14 +235,7 @@ class BoxView extends DOMWidgetView {
235235
initialize(parameters) {
236236
super.initialize(parameters);
237237
this.children_views = new ViewList(this.add_child_model, null, this);
238-
this.listenTo(this.model, 'change:children', (model, value) => {
239-
this.children_views.update(value).then((views: DOMWidgetView[]) => {
240-
// Notify all children that their sizes may have changed.
241-
views.forEach( (view) => {
242-
sendMessage(view.pWidget, ResizeMessage.UnknownSize);
243-
})
244-
});
245-
});
238+
this.listenTo(this.model, 'change:children', this.update_children);
246239
this.listenTo(this.model, 'change:box_style', this.update_box_style);
247240

248241
this.pWidget.addClass('jupyter-widgets');
@@ -255,10 +248,18 @@ class BoxView extends DOMWidgetView {
255248
*/
256249
render() {
257250
super.render();
258-
this.children_views.update(this.model.get('children'));
251+
this.update_children();
259252
this.set_box_style();
260253
}
261254

255+
update_children() {
256+
this.children_views.update(this.model.get('children')).then((views: DOMWidgetView[]) => {
257+
// Notify all children that their sizes may have changed.
258+
views.forEach( (view) => {
259+
postMessage(view.pWidget, ResizeMessage.UnknownSize);
260+
});
261+
});
262+
}
262263
update_box_style() {
263264
this.update_mapped_classes(BoxView.class_map, 'box_style');
264265
}

0 commit comments

Comments
 (0)