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

Keyboard shortcuts not working in overrides.json #15731

Open
GergelyKalmar opened this issue Feb 1, 2024 · 18 comments
Open

Keyboard shortcuts not working in overrides.json #15731

GergelyKalmar opened this issue Feb 1, 2024 · 18 comments
Labels

Comments

@GergelyKalmar
Copy link

Description

Keyboard shortcuts do not work when defined in overrides.json (as described here: https://jupyterlab.readthedocs.io/en/stable/user/directories.html#overrides-json).

Reproduce

Create a file called overrides.json and add it to the correct place (shown under "Application directory" in jupyter lab path):

{
  "@jupyterlab/apputils-extension:themes": {
    "theme": "JupyterLab Dark",
  },
  "@jupyterlab/shortcuts-extension:shortcuts": {
    "shortcuts": [
      {
        "command": "launcher:create",
        "selector": "body",
        "keys": ["Alt L"]
      }
    ]
  }
}

Start a new JupyterLab session with jupyter lab and notice that it launches with the dark theme, however, the Alt + L shortcut does not work.

Now copy the contents under @jupyterlab/shortcuts-extension:shortcuts into a user settings file (typically at ~/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings), restart the session, and notice how the keyboard shortcut now works.

Expected behavior

I would expect that keyboard shortcuts defined in overrides.json work.

Context

  • Operating System and version: Ubuntu 20.04
  • Browser and version: Chrome Version 121.0.6167.85 (Official Build) (64-bit)
  • JupyterLab version: 4.0.12

Note that the keyboard shortcuts are probably processed in overrides.json, because occasionally I can see warnings in the console about clashing options. This feature was supposedly added in this PR: #9858

Copy link

welcome bot commented Feb 1, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Feb 1, 2024
@krassowski
Copy link
Member

Thanks for the report. I believe this is a duplicate of #15713 which just got fixed by #15716 and is available in 4.1.0rc1 and will be available in 4.0.13

@GergelyKalmar
Copy link
Author

Ah cool! I missed that issue during my search because it's already closed 🙃. Any chance to release it as a small patch sometime soon? It's blocking my latest release on MindLab.

@krassowski
Copy link
Member

Any chance to release it as a small patch sometime soon?

Most likely some time next week once we get enough PRs to warrant a new patch release.

@GergelyKalmar
Copy link
Author

Works fine in 4.1, thank you very much! 🎉

@GergelyKalmar
Copy link
Author

I might have been too eager, seems like the following override doesn't work:

      {
        "command": "notebook:copy-cell",
        "keys": ["C"],
        "selector": ".jp-Notebook.jp-mod-commandMode :focus:not(:read-write)",
        "disabled": true
      },
      {
        "command": "notebook:change-cell-to-code",
        "selector": ".jp-Notebook.jp-mod-commandMode :focus:not(:read-write)",
        "keys": ["Y"],
        "disabled": true
      },
      {
        "command": "notebook:change-cell-to-code",
        "keys": ["C"],
        "selector": ".jp-Notebook.jp-mod-commandMode :focus:not(:read-write)"
      },

Any ideas? Everything else seems to work fine. Changing the key to something else (like "O") also works, but "C" does not. There seems to be no clashing or anything.

@GergelyKalmar
Copy link
Author

Changing the setting in the settings editor works fine, and it produces the exact same entry in user-settings.

@GergelyKalmar GergelyKalmar reopened this Feb 6, 2024
@krassowski
Copy link
Member

When you edit something with UI settings it will set custom values for all entries (which is not how it should work, but it is how it works today) hence the overrides.json are no longer in effect. overrides.json only sets the defaults, not the current value. When you clean it in JSON editor to {} do the overrides work?

@GergelyKalmar
Copy link
Author

Yes, I understand that I think. All of the overrides do work, except for this specific keyboard shortcut. What I meant is that if I add this configuration to the user-settings, it works, however, if I add it to the overrides.json (without having any user-settings), it doesn't.

@Michael-ljn
Copy link

Thanks for raising this issue. I face a similar one, and it is a bit frustrating if you have an international keyboard. I work with both, Australian and French keyboards. No problem with the Australian one but somehow when working with my French keyboard, "command + Z" translates to "option+W" (alt+W) which is the closing tab command. If we look at the keyboard layouts are below, and you can see that a Z input in French keyboard gives a W input in the English layout.

QWERTY (English)
AZERTY (french)

I never use that shortcut, so tried to disable, but I cannot override it or even change the input because the default one persists.

Besides this, all inputs of the French keyboard are properly read by JupyterLab, even when I try to assign a new shortcut I can see that Z is Z and W is W.

I have upgraded to Jupyterlab 4.1.6, the issue is still active.

@krassowski
Copy link
Member

I never use that shortcut, so tried to disable, but I cannot override it or even change the input because the default one persists.

Did you add the default one with disabled: true?

Of note in JupyterLab 4.2.0 (currently in beta) you can disable default shortcuts from the Keyboard Shortcuts editor, see #16043:

removeing-default

@Michael-ljn
Copy link

I did pass the following in the user preference, but there is no change, the issue persists.

"shortcuts": [
        {
            "args": {},
            "command": "application:close",
            "keys": [
                "Alt W"
            ],
            "selector": ".jp-Activity",
            "disabled": true
        }
    ]

In the beta version, if it is disabled from the editor, would that effectively work? Because it seems that the delete button is registering what I am doing manually.

@krassowski
Copy link
Member

It should work. Are you pasting the snippet above in overrides.json or in settings editor? Importantly, are you using JupyterLab or JupyterLab Desktop?

@Michael-ljn
Copy link

Michael-ljn commented Apr 10, 2024

I will give it a try. Yes, I am pasting the snippet above in the overrides.json I also tried in the settings editor. I am using JupyterLab, but I also tried on the desktop version, same issue.

@Michael-ljn
Copy link

Michael-ljn commented Apr 10, 2024

I can confirm that the issue is no longer present in 4.2.0b. I didn't need to modify the shortcut, the French input keys are now properly working for the shortcuts. Many thanks!!

@kolibril13
Copy link

just tried pip install -U --pre jupyterlab on a Mac, and overwriting shortcuts via the GUI is not working:

Screen.Recording.2024-04-18.at.13.02.31.mov

@krassowski
Copy link
Member

@kolibril13 can you open a new issue for this one?

@kolibril13
Copy link

Sure, here we go #16186

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

No branches or pull requests

5 participants