-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Fix tab trap in menubar #373
Conversation
Note that this PR does not fix all of the tab traps in JupyterLab. There are others, these two in particular:
|
TestingTesting this change against the JupyterLab UI is a little bit tricky right now. When I tried to link So I had to cherry pick the commit from this PR onto a branch based on the Lumino 1.x branch, and then do the linking. In terms of the command line, it looks like the following. First, with the Lumino repo as your current working directory:
Then, with the JupyterLab repo as current working directory (and assuming you have already pulled latest changes and installed everything):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding more information in the code comments. Otherwise it looks good to me.
Those are gonna be tricky as tab is meaningful for code editors and terminals. It may be interesting to see how vscode in its web version (aka vscode.dev or github.dev) deal with that. just tested - terminals are not available on the online version (no server to back it up) and editor are also a tab trap.
|
Co-authored-by: Frédéric Collonval <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gabalafou
return; | ||
} | ||
|
||
// A menu bar handles all other keydown events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the logic here is sound.
Originally this handler only called preventDefault
and stopPropagation
if it actually handled the key. But then the handler was rewritten to handle mnemonics. I lightly suspect that the decision to call prevent and stop on all keys was done to make the handler more readable, without too much thought given to possible negative consequences.
I wrote this PR conservatively, meaning I kept everything else about this function the same EXCEPT when the tab key is pressed. But I guess it's worth asking whether the handler should be refactored to only intercept key events that it actually does something with.
I could imagine a handler that looks more like the following:
keyDown() {
let kc = event.keyCode;
let endEvent = () => {
event.preventDefault();
event.stopPropagation();
};
// Enter, Up Arrow, Down Arrow
if (kc === 13 || kc === 38 || kc === 40) {
endEvent();
this.openActiveMenu();
return;
}
// ...
}
In other words, it would go back to looking like the original implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pursue this train of thought in another PR if necessary so we can merge this one and iterate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@meeseeksdev please backport to 1.x |
* Backport PR #373: Fix tab trap in menubar * Use key instead of keyCode * Point to stable doc on 1.x branch Co-authored-by: Afshin Taylor Darian <[email protected]> Co-authored-by: Frédéric Collonval <[email protected]>
There are a few tab traps in the JupyterLab UI. The worst offender is the top menu bar. The code change in this pull request is the most straightforward way to fix the menu bar tab trap in JupyterLab.
In terms of backwards compatibility, I have a hard time imagining that downstream dependents on Lumino would rely on the tab key event getting caught and swallowed (
event.preventDefault
+event.stopPropagation
) by the Lumino menu bar, but it is something to consider.