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

FileBrowser: Add shortcuts #10206

Merged

Conversation

martinRenou
Copy link
Member

@martinRenou martinRenou commented May 7, 2021

Adding keyboard shortcuts to Filebrowser, following vscode (and actually very common) shorcuts

shortcuts

@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@@ -138,6 +138,9 @@ export class FileBrowser extends Widget {
this.layout.addWidget(this._crumbs);
this.layout.addWidget(this._listing);

// We need to make the FileBrowser focusable so that it receives keyboard events
this.node.tabIndex = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to know if this is the right way to do this though. It's the only way I found for the filebrowser to receive keyboard events, otherwise, the body gets them (and keybindings don't get triggered).

Copy link
Member

Choose a reason for hiding this comment

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

Ah, maybe that's was why I never managed to finish #6859

Copy link
Member

Choose a reason for hiding this comment

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

I recall that @afshin dealt with some complex issues relating to focus and keybindings in the past. Perhaps he could weigh in?

Copy link
Member

Choose a reason for hiding this comment

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

It looks this may actually address some of the accessibility issues mentioned jupyterlab/frontends-team-compass#98 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to know if this is the right way to do this though. It's the only way I found for the filebrowser to receive keyboard events, otherwise, the body gets them (and keybindings don't get triggered).

I think you are right - I think only focusable elements can receive keyboard events (at least as targets), and setting the tabindex is how you make a div focusable. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex for more.

@martinRenou martinRenou force-pushed the filebrowser_delete_file_shortcut branch 2 times, most recently from a98e6ea to 9bcc078 Compare May 7, 2021 15:28
@krassowski
Copy link
Member

Would adding "go up" (see #6859) be in scope?

@martinRenou
Copy link
Member Author

Would adding "go up" (see #6859) be in scope?

I guess having it as a separate PR is good? As I am not really adding new behavior here, just adding new keybindings for already existing behaviors.

app.commands.addKeyBinding({
command: CommandIDs.open,
selector: selectorBrowser,
keys: ['Enter']
Copy link
Member

Choose a reason for hiding this comment

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

Wondering whether this Enter shortcut has some side-effects on the existing behavior of being able to create a new directory, naming it, and pressing enter to go into it?

Copy link
Member

Choose a reason for hiding this comment

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

For example the behavior looks a bit off when testing on the Binder for this branch:

new-untitled-enter.mp4

@martinRenou martinRenou force-pushed the filebrowser_delete_file_shortcut branch from 9bcc078 to 5bc97cf Compare May 11, 2021 06:27
@martinRenou
Copy link
Member Author

martinRenou commented May 11, 2021

@jtpio I am removing the Enter keybinding for now, as it is causing problems

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
Copy link
Member

jtpio commented May 11, 2021

Test failures are not related: #10228 (comment)

@jtpio
Copy link
Member

jtpio commented May 11, 2021

Possible follow-ups that could be tracked in separate issues:

  • check the existing behavior of Enter and how the keybinding mentioned above could be added later on
  • make the keybindings configurable in the settings via the shortcuts system (with the jupyter.lab.shortcuts key)

@blink1073 blink1073 added this to the 3.1 milestone May 11, 2021
@blink1073
Copy link
Member

Kicking CI

@blink1073 blink1073 closed this May 11, 2021
@blink1073 blink1073 reopened this May 11, 2021
@martinRenou martinRenou reopened this May 12, 2021
@martinRenou martinRenou reopened this May 12, 2021
@martinRenou
Copy link
Member Author

Finally green! ahah

@blink1073 blink1073 merged commit 07586c4 into jupyterlab:master May 12, 2021
@martinRenou martinRenou deleted the filebrowser_delete_file_shortcut branch May 12, 2021 13:34
cameron-toy pushed a commit to cameron-toy/jupyterlab that referenced this pull request May 28, 2021
@github-actions github-actions bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Nov 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement pkg:filebrowser status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants