From 591e73f2985cbec8117e28e378b7f7f394efc652 Mon Sep 17 00:00:00 2001 From: Mario Buikhuizen Date: Thu, 16 Jan 2025 18:37:09 +0100 Subject: [PATCH] Backport PR #3391: fix: DataMenu keeps scrolling in view after app is out of view --- CHANGES.rst | 2 ++ jdaviz/configs/default/plugins/data_menu/data_menu.vue | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 59f130a236..210e369c7a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Bug Fixes - Fixes traceback from the data-menu that can be caused by a viewer rename. [#3383] +- Fixes data-menu visibility when app is scrolled out of view. [#3391] + Cubeviz ^^^^^^^ diff --git a/jdaviz/configs/default/plugins/data_menu/data_menu.vue b/jdaviz/configs/default/plugins/data_menu/data_menu.vue index 83e386a6c2..cbb3f131bd 100644 --- a/jdaviz/configs/default/plugins/data_menu/data_menu.vue +++ b/jdaviz/configs/default/plugins/data_menu/data_menu.vue @@ -298,6 +298,7 @@ } element = element.parentElement; } + this.jupyterLabCell = this.$el.closest(".jp-Notebook-cell"); }, beforeDestroy() { let element = document.getElementById(`dm-target-${this.viewer_id}`).parentElement @@ -326,6 +327,11 @@ if (this.data_menu_open && document.getElementById(`dm-target-${this.viewer_id}`)) { const menuContent = document.getElementById(`dm-content-${this.viewer_id}`); menuContent.parentElement.style.top = top + "px"; + + /* since Jupyter Lab 4.2 cells outside the view port get a height of 0, causing the menu to be visible when + * that happens. This workaround hides the menu when it's parent cell is not in the viewport. */ + const labCellHidden = this.jupyterLabCell && window.getComputedStyle(this.jupyterLabCell).height === "0px"; + menuContent.parentElement.style.display = labCellHidden ? "none" : ""; } }, boolToString(b) {