jupyterlab
jupyterlab copied to clipboard
Resizing window should keep current cell visible
Problem
- I'm always frustrated when I switch between tiled window and maximized window because the cell in view is changed to somewhere far away.
- I would like it if it keeps the current cell in view no matter how I resize windows.
Proposed Solution
- Make it keep the current cell in view no matter how I resize windows.
Additional context
- Using chrome
I'm not sure exactly what you're asking for here. Can you attach screenshots of the "before" and "after" UI, with markup to indicate what you are asking for?
For example, when I have 600 cells and at last cell on maximazed window. After resize to 1/4 of screen size. The view could jump to the middle like number 400 of all the cells.

This one is gonna be though. Basically the current focus is in the active cell (the one with blue border). So when you resize, JupyterLab will bring that focused cell in the view assuming it is the main focus.
To change that, it will require to track the current cells seen in the viewport before the resize event.
But it' s not the cell with blue border in view after resize?
So when you resize, JupyterLab will bring that focused cell in the view assuming it is the main focus.
I concur with @xgdgsc, the active cell is not in the view after resizing for me either. I think that we have an agreement that it would be nice to call scrollToCell(activeCell) on resize; it is defined here:
https://github.com/jupyterlab/jupyterlab/blob/f573c4a7bd55e3eafbd3667716fe55b431021d9a/packages/notebook/src/widget.ts#L1599
but it looks like onResize does not do that as of now:
https://github.com/jupyterlab/jupyterlab/blob/f573c4a7bd55e3eafbd3667716fe55b431021d9a/packages/notebook/src/widget.ts#L1739-L1761
Notes:
- I am not convinced whether we should call
scrollToCell(activeCell)on every resize, or only when the resize was "substantial", i.e. moved the cell outside of the view. - the call would need to happen only after the layout settled (all updates to the height of cells were applied).
Also happens when using "New view for notebook".
Also happens when toggle side bar with ctrl+b.
Yes, this is an important and practically relevant issue.
- Adding and removing columns to the window layout for a side-by-side view, for example, happens frequently and changes the height of cells as a consequence of reduced width.
- Switching to full-screen view (maximized window or F11) in order to see a full view e.g. of a generated very large graph or for presentation, also shifts the vertical position.
This jump out-of-view prompts unnecessary searching and scrolling up and down, not even knowing where the previously visible cell (which is not always the active one) went.
What a hassle, that disturbs the flow of work.