Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing window should keep current cell visible #12807

Open
xgdgsc opened this issue Jul 18, 2022 · 9 comments
Open

Resizing window should keep current cell visible #12807

xgdgsc opened this issue Jul 18, 2022 · 9 comments

Comments

@xgdgsc
Copy link

xgdgsc commented Jul 18, 2022

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
@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Jul 18, 2022
@JasonWeill
Copy link
Contributor

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?

@xgdgsc
Copy link
Author

xgdgsc commented Jul 22, 2022

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
Copy link
Author

xgdgsc commented Jul 22, 2022

Peek 2022-07-22 11-09

@fcollonval
Copy link
Member

fcollonval commented Jul 22, 2022

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.

@xgdgsc
Copy link
Author

xgdgsc commented Jul 24, 2022

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

@krassowski
Copy link
Member

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:

scrollToCell(cell: Cell): void {

but it looks like onResize does not do that as of now:

protected onResize(msg: Widget.ResizeMessage): void {
if (!this._checkCacheOnNextResize) {
return super.onResize(msg);
}
this._checkCacheOnNextResize = false;
const cache = this._cellLayoutStateCache;
const width = parseInt(this.node.style.width, 10);
if (cache) {
if (width === cache.width) {
// Cache identical, do nothing
return;
}
}
// Update cache
this._cellLayoutStateCache = { width };
// Fallback:
for (const w of this.widgets) {
if (w instanceof Cell) {
w.editorWidget.update();
}
}
}

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

@JasonWeill JasonWeill changed the title Resizing window preserve cell in view Resizing window should keep current cell visible Aug 4, 2022
@JasonWeill JasonWeill added tag:Design and UX and removed status:Needs Info status:Needs Triage Applied to new issues that need triage labels Aug 4, 2022
@xgdgsc
Copy link
Author

xgdgsc commented Sep 5, 2022

Also happens when using "New view for notebook".

@xgdgsc
Copy link
Author

xgdgsc commented Oct 13, 2022

Also happens when toggle side bar with ctrl+b.

@creative-resort
Copy link

creative-resort commented Jun 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants