Skip to content

Fix toggling the side panels from menu#7799

Merged
jtpio merged 5 commits intojupyter:mainfrom
brichet:fix_sidepanel_activate
Jan 12, 2026
Merged

Fix toggling the side panels from menu#7799
jtpio merged 5 commits intojupyter:mainfrom
brichet:fix_sidepanel_activate

Conversation

@brichet
Copy link
Collaborator

@brichet brichet commented Jan 8, 2026

This PR reverts #7178.

#7178 changes the behavior of panel.expand(), and toggle the panel instead of expanding it. Therefore, the command shell.activateById can collapse the side panel, which is not the expected behavior most of the time.

References

Fixes (again) #7147
Fixes #7534
Fixes #7790 (comment)
Related to jupyterlab/jupyter-chat#105 (comment) (workaround at https://github.com/jupyterlab/jupyter-chat/blob/5b4040e83374470375eb090683f4850f9df7dd2d/packages/jupyterlab-chat-extension/src/index.ts#L697-L699)

Code changes

  • Revert Fix toggle functionality for widgets. #7178
  • Add some method in shell to:
    • get the area of a widget
    • check if a side panel is visible from area
    • expand a panel from area
    • collapse a panel from area
  • Add a plugin to override the upstream menu items "Table of Contents" and "Debugger Panel" to toggle the panels instead of activating them.

User-facing changes

Do not hide a side panel when using shell.activateById() anymore.

Backwards-incompatible changes

None

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Binder 👈 Launch a Binder on branch brichet/notebook/fix_sidepanel_activate

@brichet
Copy link
Collaborator Author

brichet commented Jan 8, 2026

I wanted to replace the menu item or the command relative to the TOC and the debugger, with a commands toggling the side panel.
But I couldn't find a way to disable (using public API) a core command from an extension, or to remove an item.

Perhaps fixing #7147 should be done upstream in Jupyterlab, by changing the commands to toggle instead of activate ?

@brichet brichet changed the title Revert "Fix toggle functionality for widgets. (#7178)" Fix toggling the side panels from menu Jan 8, 2026
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried unsuccessfully to replace the upstream shortcuts, but it seems to also disable the new shortcuts

"jupyter.lab.shortcuts": [
    {
      "command": "toc:show-panel",
      "disabled": true,
      "keys": ["Accel Shift K"],
      "selector": "body"
    },
    {
      "command": "toc:toggle-panel",
      "keys": ["Accel Shift K"],
      "selector": "body"
    },
    {
      "command": "debugger:show-panel",
      "disabled": true,
      "keys": ["Accel Shift E"],
      "selector": "body"
    },
    {
      "command": "debugger:toggle-panel",
      "keys": ["Accel Shift E"],
      "selector": "body"
    }
  ]

@brichet brichet marked this pull request as ready for review January 8, 2026 16:30
@brichet
Copy link
Collaborator Author

brichet commented Jan 8, 2026

I wanted to replace the menu item or the command relative to the TOC and the debugger, with a commands toggling the side panel. But I couldn't find a way to disable (using public API) a core command from an extension, or to remove an item.

Perhaps fixing #7147 should be done upstream in Jupyterlab, by changing the commands to toggle instead of activate ?

Finally the menu item can be disabled from the settings.
Thanks @jtpio for the tip.

@jtpio jtpio added this to the 7.6.0 milestone Jan 12, 2026
"disabled": true
},
{
"command": "toc:toggle-panel",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this menu entry show up if the TOC extension is disabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the command is created only if the TOC tracker token (ITableOfContentsTracker) is provided https://github.com/jupyter/notebook/pull/7799/files#diff-9bfcf1dd55d0d858225f19d220d93e635e9f83f14bd735a3958156a244345d24R786.
This is the same for the debugger, which expects IDebuggerSidebar token.

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 1475851 into jupyter:main Jan 12, 2026
33 of 34 checks passed
@brichet brichet deleted the fix_sidepanel_activate branch January 12, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

activateById toggle side panel instead of expanding it

2 participants