debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Accessibility] There should be a way to get out of the CodeMirror section with the keyboard.

Open yzen opened this issue 9 years ago • 10 comments

Right now if keyboard focus lands inside the code mirror section, there is no way to get out of it which in turn creates a keyboard trap.

Perhaps a good approach is to be able to press ESC that would shift focus on the code mirror container so the consequent tabs/shift+tabs will result in navigation to the next/previous sections outside of the code mirror section.

Also it would be nice to not automatically step into code when navigating with the keyboard and instead focus on the container. To step into code, the user could press Enter/Space to activate.

The mouse behaviour should remain the same.

yzen avatar Sep 18 '17 17:09 yzen

this is an interesting problem. The pattern with devtools is that escape should open the console. Infact, i think most people would consider it a bug if we don't do that. Unfortunately, that takes moves focus pretty far out of the current context.

jasonLaster avatar Sep 18 '17 17:09 jasonLaster

Also, escape is problematic if say a tooltip is open. As escape should close the tooltips in the editor without removing focus. Escaping within CM is not a clear-cut thing as to what expected results should be.

Shift+Tab currently has no context in CodeMirror. So we could hijack this as our escape hatch. But, I'd much prefer we try to collaborate with this with the Chrome DevTools and Edge teams as well. This affects all of us from what I can tell and we should all find a consistent way for everyone to implement so this is stable across toolsets. If we do one key combo and another toolset decides esc is in fact the proper solution, then we're making a space complex for users that really need these that shouldn't be.

Garbee avatar Sep 20 '17 11:09 Garbee

/claim

WaltersJesse avatar Oct 10 '17 17:10 WaltersJesse

Thanks for claiming the issue! :wave:

Here are some link for getting setup, contributing, and development tips. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Oct 10 '17 17:10 claim

Some thoughts: The problem with code mirror is twofold, imo. Firstly, for efficiency, tabbing to the CodeMirror area should not move the focus straight into the the editable space. The focus should remain on the container and editing state should be triggered by user action (e.g. pressing Enter/Space). If user activates code mirror, focus moves inside as it currently does. If the user carries on with tabbing/shift-tabbing, the focus moves forward/back without stepping inside. Secondly, the keyboard trap itself. Originally I proposed Escape because this is what we settled on when working on keyboard accessibility for our DevTools Inspector. If the state of the inspector is in edit mode, escape reverts it to read only mode and only the second escape triggers the console. So the precedent is already there, for several releases, without much negative feedback, afaik. Alternatively, a shortcut that could potentially work could be Ctrl[Cmd]+Tab for tabbing forward away from the editable area and Shift+Ctrl[Cmd]+Tab for tabbing back. This however must be discoverable in some sort of way since it's not something the user can intuitively figure out.

yzen avatar Nov 15 '17 04:11 yzen

/unclaim My team members and I have not solved the bug entirely, but we do have some thoughts and possibly a place to start looking.

To attempt to fix the bug, we changed code in two files: In src/utils/editor/editor/index.js we made the following changes: we specified a keybind (Ctrl+Shift+Tab) to enter and exit the CodeMirror when navigating with the keyboard.

In /src/components/Editor/index.js we made the following changes: we modified the onKeyDown function at line 283 with a conditional that will handle our keybind (Ctrl + Shift + Tab for the sake of simplicity). The new conditional looks like: if (key ==="Ctrl + Shift + Tab" && target == textArea) and inside we called the stopPropogation function

we modified the componentDidMount function in this file and added a line: shortcuts.on("Ctrl + Shift+Tab", this.ourFunction);

We also had changes that we did not get a chance to implement: In src/utils/editor/editor/index.js: We will need to modify the extraKeys dictionary that is initialized in the createEditor function in index.js and add the keybind.

In /src/components/Editor/index.js: We planned to call a function to shift focus to the source list pane. This function would shift focus back into the source list pane when the keybind is activated. The function would be located in this file and be similar to onEscape, but for the keybind.

Here is a git diff showing our changes.

capture

WaltersJesse avatar Dec 10 '17 22:12 WaltersJesse

I'm moving this to the icebox, we'll re-evaluate in the next release process.

If you're interested in working on it, feel free to claim it.

jasonLaster avatar Mar 12 '18 22:03 jasonLaster

@WaltersJesse Hey Jesse, wondering if this issue have solved. Just tried keybind(Ctrl+Shift+Tab), not working -.-

jfeng21 avatar Jan 31 '19 02:01 jfeng21

@jfeng21 i believe this is not being worked on. Would you like to try and fix this?

jasonLaster avatar Jan 31 '19 15:01 jasonLaster

I think @nchevobbe worked on a similar issue for the Console, with a patch reviewed by @yzen. Perhaps the same solution could apply here, or we could learn something from it?

fvsch avatar Feb 03 '19 11:02 fvsch