From 08f8634b6f86864dc9b6448e35a28bf84131ca30 Mon Sep 17 00:00:00 2001 From: Mario Buikhuizen Date: Thu, 16 Jan 2025 11:24:07 +0100 Subject: [PATCH] fix: DataMenu keeps scrolling in view after app is out of view --- jdaviz/configs/default/plugins/data_menu/data_menu.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdaviz/configs/default/plugins/data_menu/data_menu.vue b/jdaviz/configs/default/plugins/data_menu/data_menu.vue index 792edc4dcf..59049e80ed 100644 --- a/jdaviz/configs/default/plugins/data_menu/data_menu.vue +++ b/jdaviz/configs/default/plugins/data_menu/data_menu.vue @@ -297,6 +297,7 @@ } element = element.parentElement; } + this.jupyterLabCell = this.$el.closest(".jp-Notebook-cell"); }, beforeDestroy() { let element = document.getElementById(`dm-target-${this.viewer_id}`).parentElement @@ -325,6 +326,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) {