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

Focus notebook output #97185

Merged
merged 10 commits into from May 8, 2020
Merged

Conversation

ctmayn
Copy link
Contributor

@ctmayn ctmayn commented May 7, 2020

These changes allow focus to be set within the output of a notebook cell using only the keyboard.
While this PR makes it partially accessible there are still a couple issues (and possibly a few more undiscovered ones) that need to be handled before considering the issue fixed:

  • The Ctrl + Up and Ctrl + Down commands should be made customizable.
  • Some of the other shortcuts should not be usable while focused on the output. (Like delete)
  • Tests should be added for this behavior

This PR fixes #93896

@@ -405,6 +466,14 @@ ${loaderJs}
initialize(content: string) {
this.webview = this._createInset(this.webviewService, content);
this.webview.mountTo(this.element);
this.webview.onDidFocus(() => {
if (this.activeCellId) {
this.webview.sendMessage({
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if this will break users' regular operations like clicking a button, selecting some text, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this.activeCellId = undefined after calling the focus listener. This should ensure that the message is sent only once per Ctrl + UpArrow in and will never send on focus via mouse. I'll leave this unresolved though in case I missed something.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine for now, I will probably mess around with it. @rebornix We saw a weird issue if we send this message immediately after calling webview.focus() without waiting

let lowerWrapperElement = document.createElement('div');
lowerWrapperElement.tabIndex = 0;
container.appendChild(lowerWrapperElement);
lowerWrapperElement.addEventListener('focus', () => {
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -310,6 +336,32 @@ ${loaderJs}
data: { }
});
});

const handleKeyDown = (event) => {
if (event.defaultPrevented || !(event.key === 'ArrowUp' && event.ctrlKey)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be a command with keybinding, I can make that change.

Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -207,11 +208,11 @@ registerAction2(class extends Action2 {
// Try to select below, fall back on inserting
const nextCell = editor.viewModel?.viewCells[idx + 1];
if (nextCell) {
editor.focusNotebookCell(nextCell, activeCell.editState === CellEditState.Editing);
editor.focusNotebookCell(nextCell, activeCell.editState === CellEditState.Editing ? 'editor' : 'container');
Copy link
Member

Choose a reason for hiding this comment

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

we can add an enum to notebookCommon

@roblourens roblourens merged commit 0a3df93 into microsoft:master May 8, 2020
@roblourens
Copy link
Member

Thanks @ctmayn!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebook cell results fully unaccessible
3 participants