Skip to main content

jupyterlab_other_file_type_menu_fix

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

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

Metadata

Release files for jupyterlab-other-file-type-menu-fix 1.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-other-file-type-menu-fix 1.0.14
File Size Uploaded
jupyterlab_other_file_type_menu_fix-1.0.14.tar.gz 368.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-other-file-type-menu-fix 1.0.14
File Interpreter ABI Platform
jupyterlab_other_file_type_menu_fix-1.0.14-py3-none-any.whl Python 3 none any Details

Total release size: 384.3 kB

Release files / jupyterlab_other_file_type_menu_fix-1.0.14.tar.gz

Download URL jupyterlab_other_file_type_menu_fix-1.0.14.tar.gz
Size 368.1 kB
Tags Source
SHA-256 checksum
How to use checksums
59d8af1a4d8d7b05e86f960fd26418e68d4821c7ad25c1717f87f93db0953068
BLAKE2b-256 checksum
How to use checksums
7db65b3825708ff94f6ff46cea3ea6eb2f25390cc0236ae9c666558460ea3e88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / jupyterlab_other_file_type_menu_fix-1.0.14-py3-none-any.whl

Download URL jupyterlab_other_file_type_menu_fix-1.0.14-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f4da1d35f4d2fe0eea4d098e9fb4e12b72adbbbf96be5b6a70794c6461da276
BLAKE2b-256 checksum
How to use checksums
c9bdfcf8f07897b04746efdab69eed368969863b6870706cd1cfe45e1e9d5524
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.0.14 This release

2 release files

1.0.10

2 release files

1.0.8

2 release files

1.0.4

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page