Bug 147927

Summary: Web Inspector: Control-backtick should focus on the console prompt
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
bburg: review+
Patch none

Description Nikita Vasilyev 2015-08-12 00:00:56 PDT
This is a feedback from https://twitter.com/glenmaddern.

Esc key focuses on the console prompt line, unless:
— the text cursor is in a text field (e.g. the global search field at the top right corner, filter fields, etc.)
— the text cursor is in the styles sidebar
— the text cursor is inside of any CodeMirror view
— DOM node content/attribute is being edited in Elements
— there is a text selection
— <select> menu is opened
— autocomplete suggestion is opened
— a message in the Console tab is already selected (needs two Esc presses to focus on the prompt, not one)

The list goes on and on.

We need a keyboard shortcut that would just focus on the console prompt so one could press it with their eyes closed and start typing console commands, no matter which more they're in.
Comment 1 Timothy Hatcher 2015-08-12 00:05:15 PDT
Sounds good, as long as escape still works. Does Chrome have a better one? Esc still works there with similar caveats. (Actually it just opens and closes the drawer, it doesn't show the Console in the drawer. Eww.)
Comment 2 Nikita Vasilyev 2015-08-12 00:20:26 PDT
No, not really. Command-Option-J opens console and focuses on the prompt line if Chrome DevTools are closed. It closes the DevTools if it's already opened.

Esc doesn't trigger autocomplete in Chrome, so the issue is less severe. It can also open the split console when HTML/CSS/JS resource is being edited, unlike in WebKit Inspector.
Comment 3 Nikita Vasilyev 2015-08-17 00:26:44 PDT
Chrome DevTools also has Control ~ (tilde), which does exactly what I have proposed. We should support it.
Comment 4 Radar WebKit Bug Importer 2015-08-17 00:26:58 PDT
<rdar://problem/22304177>
Comment 5 Devin Rousso 2015-08-17 11:24:02 PDT
Created attachment 259165 [details]
Patch

Just FYI, you can also press Option+Command+C to immediately switch to the console tab and focus the prompt.  It isn't as subtle as toggling the split console, but it works.
Comment 6 Nikita Vasilyev 2015-08-17 23:08:43 PDT
Comment on attachment 259165 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259165&action=review

Option+Command+C also doesn't work when:
— the text cursor is in a text field (e.g. the global search field at the top right corner, filter fields, etc.)
— the text cursor is in the styles sidebar
— the text cursor is inside of any CodeMirror view
— <select> menu is opened

> Source/WebInspectorUI/UserInterface/Base/Main.js:248
> +    this._quickConsoleKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, WebInspector.KeyboardShortcut.Key.Apostrophe, this.showSplitConsole.bind(this));

This focuses on the console prompt and opens the split console. I think we should just focus on the prompt, nothing else.
Comment 7 Devin Rousso 2015-08-18 10:26:42 PDT
(In reply to comment #6)
> Option+Command+C also doesn't work when:
> — the text cursor is in a text field (e.g. the global search field at the
> top right corner, filter fields, etc.)
> — the text cursor is in the styles sidebar
> — the text cursor is inside of any CodeMirror view
> — <select> menu is opened

I am actually seeing Option+Command+C working in all but the <select> scenario.  It's bound in Main.js so it fires before everything else.  For the <select>, I don't think that there is anything we can do there since that is system behavior.
Comment 8 Devin Rousso 2015-08-18 10:32:30 PDT
Created attachment 259278 [details]
Patch
Comment 9 BJ Burg 2015-08-18 10:41:20 PDT
Comment on attachment 259278 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259278&action=review

r=me

> Source/WebInspectorUI/ChangeLog:11
> +        Added a keyboard shortcut to focus the console prompt.

Please say here what the new keyboard shortcut *is*.
Comment 10 Devin Rousso 2015-08-18 10:54:29 PDT
Created attachment 259281 [details]
Patch
Comment 11 WebKit Commit Bot 2015-08-18 11:47:52 PDT
Comment on attachment 259281 [details]
Patch

Clearing flags on attachment: 259281

Committed r188586: <http://trac.webkit.org/changeset/188586>
Comment 12 WebKit Commit Bot 2015-08-18 11:47:56 PDT
All reviewed patches have been landed.  Closing bug.