jupyterlab icon indicating copy to clipboard operation
jupyterlab copied to clipboard

Resizing window should keep current cell visible

Open xgdgsc opened this issue 3 years ago • 7 comments

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

xgdgsc avatar Jul 18 '22 03:07 xgdgsc

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?

JasonWeill avatar Jul 21 '22 17:07 JasonWeill

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.

xgdgsc avatar Jul 22 '22 03:07 xgdgsc

Peek 2022-07-22 11-09

xgdgsc avatar Jul 22 '22 03:07 xgdgsc

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.

fcollonval avatar Jul 22 '22 09:07 fcollonval

But it' s not the cell with blue border in view after resize?

xgdgsc avatar Jul 24 '22 00:07 xgdgsc

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).

krassowski avatar Jul 24 '22 12:07 krassowski

Also happens when using "New view for notebook".

xgdgsc avatar Sep 05 '22 08:09 xgdgsc

Also happens when toggle side bar with ctrl+b.

xgdgsc avatar Oct 13 '22 07:10 xgdgsc

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.

creative-resort avatar Jun 08 '23 05:06 creative-resort