Skip to main content

Jupyterlab fix delivered as extension that fixes annoying issue where a non-standard type file (e.g. LICENSE or .gitignore or any other) doesn't have a standard menu, and the context menu that displays doesn't have refresh view command and doesn't properly show the menu items and doesn't highlight current hover over pointed item

Project description

jupyterlab_other_file_type_menu_fix

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

[!WARNING] This extension is a workaround for a JupyterLab core bug. It will be deprecated and removed once the fix is included in an official JupyterLab release. If you are running a JupyterLab version where the context menu works correctly for unregistered file types, you no longer need this extension.

Fixes the broken context menu for non-standard file types in JupyterLab. When you open files like LICENSE, .gitignore, Dockerfile, or any file without a registered type and right-click, the context menu shows stale items from the previously focused widget - items are inert and hover highlighting is broken. This extension forces proper widget activation before the Lumino context menu resolves, ensuring the correct menu appears.

Without fix With fix
Context menu broken Context menu working

Features

  • Fixes stale context menu - right-clicking in files without a registered type now shows the correct context menu instead of a repeat of the last valid file's menu
  • Restores menu interactivity - context menu items are properly connected to the current widget, so clicks actually work
  • Fixes hover highlighting - menu item hover states render correctly
  • Zero side effects - does not register new file types or override icons from other extensions (compatible with vscode-icons and similar icon packs)

Root cause

JupyterLab's document registry maps file extensions to file types via DocumentRegistry.getFileTypesForPath(). Files without a recognized extension or name pattern - such as LICENSE, Makefile, or any custom-named file - return an empty match. The file still opens correctly in a FileEditor because the registry falls back to the generic text type, but the widget may not be the shell's currentWidget when the Lumino context menu fires.

Lumino's context menu resolves which commands to display (and their isEnabled/isVisible state) against shell.currentWidget. If the user right-clicks on an unregistered file type after having focused a different widget, the context menu renders commands for the previous widget. The result is a stale menu with inert items and broken hover highlighting because the command targets don't match the visible editor.

How it works

The extension registers a DocumentRegistry.WidgetExtension on the 'Editor' factory via addWidgetExtension(). This attaches a capture-phase contextmenu event listener on every FileEditor widget's own DOM node. When the user right-clicks, the listener calls shell.activateById() for that specific widget before the event reaches Lumino's document-level handler. By the time Lumino resolves context menu commands, the correct widget is already active.

This approach is deterministic and widget-scoped - each widget takes responsibility for its own activation rather than relying on a global event interceptor. It does not register file types, so it cannot interfere with icons provided by vscode-icons or other extensions.

Installation

Requires JupyterLab 4.0.0 or higher.

pip install jupyterlab_other_file_type_menu_fix

Uninstall

pip uninstall jupyterlab_other_file_type_menu_fix

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_other_file_type_menu_fix-1.0.10.tar.gz (367.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file jupyterlab_other_file_type_menu_fix-1.0.10.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_other_file_type_menu_fix-1.0.10.tar.gz
Algorithm Hash digest
SHA256 e4c13ca53b3dab64e24dec82884479da4413fa87d1f01c59b559aabc6fc31b44
MD5 49baed6b8c5bf4636422387be967ddd9
BLAKE2b-256 6c07e6a0756e3d52e812e8cf89cad3f7c23f995d9691d7bcc58f5425be08bcdc

See more details on using hashes here.

File details

Details for the file jupyterlab_other_file_type_menu_fix-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_other_file_type_menu_fix-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a366ad89a35a0ade6f434c9d1f4e705ac89b388fd2233ae5097ba805ff7394c4
MD5 6a2f3bab4ce8c29bb24c285d12c17ec8
BLAKE2b-256 6ae1d7eb1bef52ddf1a8fce78d1316aab8335fb9e4e490dc9ca8a7de171e0d02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page