Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not wait for "displayed" before applying the layout #3288

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,9 @@ export class DOMWidgetView extends WidgetView {
}
);

this.displayed.then(() => {
this.update_classes([], this.model.get('_dom_classes'));
this.setLayout(this.model.get('layout'));
this.setStyle(this.model.get('style'));
});
this.update_classes([], this.model.get('_dom_classes'));
this.setLayout(this.model.get('layout'));
this.setStyle(this.model.get('style'));

this._comm_live_update();
this.listenTo(this.model, 'comm_live_update', () => {
Expand All @@ -920,23 +918,25 @@ export class DOMWidgetView extends WidgetView {
oldLayoutView.remove();
}

return this.create_child_view(layout)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to revert this

this.create_child_view(layout)
.then((view) => {
// Trigger the displayed event of the child view.
return this.displayed.then(() => {
view.trigger('displayed');
this.listenTo(view.model, 'change', () => {
// Post (asynchronous) so layout changes can take
// effect first.
MessageLoop.postMessage(
this.luminoWidget,
Widget.ResizeMessage.UnknownSize
);
});
this.trigger('layout-applied');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a "layout-applied" event to the widget, we need to document this

this.listenTo(view.model, 'change', () => {
// Post (asynchronous) so layout changes can take
// effect first.
MessageLoop.postMessage(
this.luminoWidget,
Widget.ResizeMessage.UnknownSize
);
});
MessageLoop.postMessage(
this.luminoWidget,
Widget.ResizeMessage.UnknownSize
);

// Trigger the displayed event of the child view.
return this.displayed.then(() => {
view.trigger('displayed');
return view;
});
})
Expand All @@ -956,7 +956,7 @@ export class DOMWidgetView extends WidgetView {
oldStyleView.remove();
}

return this.create_child_view(style)
this.create_child_view(style)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are reverting the other one, we should also revert this one.

.then((view) => {
// Trigger the displayed event of the child view.
return this.displayed.then(() => {
Expand Down