jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
14.17k stars 3.39k forks source link

Tag an output type not to be detached when out of the view #16630

Open ManonMarchand opened 3 months ago

ManonMarchand commented 3 months ago

Hi Jupyter's team,

Problem

In custom anywidgets, it would be nice if we could avoid detaching the widget when it's out of view.

The issue is quite concrete in ipyaladin an astrophysics widget, where the size of the canvas in the widget represents what a telescope can see, and some operations can be done on the field of view or on the pixels, even when the widget is out of the view.

See this gif to see the issue:

scroll_out_of_view

when the widget is out of view, its size changes, and the pixels are not available anymore.

Proposed Solution

I noticed that there is no issue if the cell is selected. I think this is related to https://github.com/jupyterlab/jupyterlab/pull/16006 Would it be possible to add a mechanism to remove certain output types from the list of windowed things?

krassowski commented 3 months ago

Hello :wave: and thank you for proposing this! Yes, I think this would make sense to allow outputs to mark themselves as "please do not detach me". I think we had discussions about doing that with outputs that contain iframes.

ManonMarchand commented 3 months ago

That'd be awesome!