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

fix: golden layout not rendering when created outside viewport #3299

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Bug Fixes

- Added ``nbclassic`` dependency to fix ``solara``-based popouts. [#3282]

- Fixed viewer widgets displaying improperly if initialized out of view in Jupyter Lab. [#3299]

Cubeviz
^^^^^^^

Expand Down
15 changes: 14 additions & 1 deletion jdaviz/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<splitpanes>
<pane size="75">
<golden-layout
v-if="outputCellHasHeight"
style="height: 100%;"
:has-headers="state.settings.visible.tab_headers"
@state="onLayoutChange"
Expand Down Expand Up @@ -174,6 +175,11 @@

<script>
export default {
data() {
return {
outputCellHasHeight: false,
};
},
methods: {
checkNotebookContext() {
this.notebook_context = document.getElementById("ipython-main-app")
Expand All @@ -200,6 +206,13 @@ export default {
if (jpOutputElem) {
jpOutputElem.classList.remove('jupyter-widgets');
}
/* Workaround for Lab 4.2: cells outside the viewport get the style "display: none" which causes the content to not
* have height. This causes an error in size calculations of golden layout from which it doesn't recover.
*/
new ResizeObserver(entries => {
this.outputCellHasHeight = entries[0].contentRect.height > 0;
}).observe(this.$refs.mainapp.$el);
this.outputCellHasHeight = this.$refs.mainapp.$el.offsetHeight > 0
}
};
</script>
Expand All @@ -214,4 +227,4 @@ export default {
.plugin-title.v-list-item:after {
display: none !important;
}
</style>
</style>