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

Statusbar buttons are not giving back the keyboard focus to the editor #145432

Closed
Z-E-D opened this issue Mar 18, 2022 · 6 comments
Closed

Statusbar buttons are not giving back the keyboard focus to the editor #145432

Z-E-D opened this issue Mar 18, 2022 · 6 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@Z-E-D
Copy link

Z-E-D commented Mar 18, 2022

Does this issue occur when all extensions are disabled?: No, but I think the problem is with the VBCode extensions API.

  • VS Code Version: 1.65.0
  • OS Version: Windows 7

Steps to Reproduce:

  1. install statusbar-commands extension
  2. enter the next lines into settings.json and save it:
    "statusbar_command.commands": [
        {
            "text": "$(save)",
            "id": "sbc_saveWithoutFormatting",
            "name": "Save Without Formatting",
            "tooltip": "Save Without Formatting (Ctrl+K Ctrl+Shift+S)",
            "priority": -100,
            "alignment": "left",
            "command": "workbench.action.files.saveWithoutFormatting"
        }
    ]
  1. open any file and make some changes in it
  2. click on the status bar button that was previously created by the mentioned extension
  3. file is saved, but the keyboard focus is not returned to the editor.

There are several extensions that I tried, which have possibility to create custom status bar buttons that allow executing of specified VSCode commands, including the mentioned one and the Commands extension, that have the same problem. So, I don't think that the problem is with these extensions, but with the VSCode API exposed by the program that they are using.

There are many VSCode commands, which could be assigned to the status bar buttons with the help of these extensions, that are not giving back the focus to the editor like these:

  • "Save",
  • "Toggle Line Comment" / "Toggle Block Comment",
  • "Go to Bracket",
  • "Go to Parent Fold" / "Go to Previous/Next Folding Range",
  • "Go to Definition",
  • "Go to Previous/Next Symbol Highlight",
  • "Toggle Full Screen",
  • "Toggle Split Editor in Group Layout",
  • ...

On other side, there are some commands that are not stealing the focus from editor, like these:

  • "Undo" / "Redo",
  • "Go Back" / "Go Forward",
  • "Go to Last Edit Location",
  • "Toggle Split Editor in Group",
  • ...

If you are interested in more details about this problem, you could read my report to the author of the statusbar-commands extension where I described a workaround for this problem using another extension.

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

file is saved, but the keyboard focus is not returned to the editor

The fact that keyboard focus remains in the status bar is likely for accessibility reasons. And why can the extension not simply pass focus back to the editor?

@bpasero bpasero added the info-needed Issue requires more information from poster label Mar 22, 2022
@Z-E-D
Copy link
Author

Z-E-D commented Mar 22, 2022

Of course it is possible to give the focus back to the editor using extensions. I described a workaround for that in the linked report, by adding "workbench.action.focusActiveEditorGroup" to the wanted command with the help of multi-command extension.

The thing is that such behavior is inconsistent and unneeded:

  1. there are commands invoked from the statusbar that don't take focus from the editor, e.g. Undo or Go Back (how these commands don't have problem with the accessibility?);

  2. the same commands that are taking focus when invoked from the statusbar don't do that when they are invoked:
    a) from the menu using the native menu item;
    b) from the toolbar using buttons created by extensions with the same command (e.g. the Save button from ShortcutMenuBar extension doesn't take focus).

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

The status bar part is really just executing commands:

await this.commandService.executeCommand(id, ...args);

It does not do anything with regards to focus or not. It is up to the command to focus the editor or not focus the editor.

I would argue the status bar does everything right and if there is a command that steals focus from the status bar, then I would have a discussion with the specific command whether that makes sense or not.

Can you give an example of a command (from us, not from an extension) that should behave differently?

@Z-E-D
Copy link
Author

Z-E-D commented Mar 22, 2022

I don't know how your program works internally. I am just beginner with it and I sorry for my ignorance. I am looking at this as an average user and as a user I see this behavior inconsistent, as I explained already:

  1. the Save command is stealing focus, the Undo command is not -> this is inconsistent;
  2. the Save command executed from statusbar is stealing focus, the same command executed from menu or toolbar is not - this is inconsistent.

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

I have no "Save" command in the status bar, nor do I have "Undo/Redo". We do not ship these commands by default. It sounds to me you have some kind of extension installed, then I suggest to file the issue against the extension.

@Z-E-D
Copy link
Author

Z-E-D commented Mar 22, 2022

Yes, I posted the issue to the author of the extension who suggested that I post issue to you. As I already mentioned, the problem is not with single extension, but with all extensions that are creating statusbar buttons. All these extensions use the same, standard API for executing commands, exposed by VSCode.

By the way, here is the more detail list of commands that are not giving back focus:

  • "Save Without Formatting": "workbench.action.files.saveWithoutFormatting",
  • "Toggle Line Comment": "editor.action.commentLine",
  • "Toggle Block Comment": "editor.action.blockComment",
  • "Go to Bracket": "editor.action.jumpToBracket",
  • "Go to Parent Fold": "editor.gotoParentFold",
  • "Go to Previous Folding Range": "editor.gotoPreviousFold",
  • "Go to Next Folding Range": "editor.gotoNextFold",
  • "Go to Previous Symbol Highlight": "editor.action.wordHighlight.prev",
  • "Go to Next Symbol Highlight": "editor.action.wordHighlight.next",
  • "Find Previous Selection": "editor.action.previousSelectionMatchFindAction",
  • "Find Next Selection": "editor.action.nextSelectionMatchFindAction",
  • "Toggle Full Screen": "workbench.action.toggleFullScreen",
  • "Toggle Vertical/Horizontal Editor Layout": "workbench.action.toggleEditorGroupLayout",
  • "Toggle Word Wrap": "editor.action.toggleWordWrap",
  • "Toggle Minimap": "editor.action.toggleMinimap",
  • "Toggle Breadcrumbs": "breadcrumbs.toggle",
  • "Toggle Tab Visibility": "workbench.action.toggleTabsVisibility",
  • "Inspect Editor Tokens and Scopes": "editor.action.inspectTMScopes"

And here are the commands that are giving back focus to the editor.

  • "Undo": "undo",
  • "Redo": "redo",
  • "Go Back": "workbench.action.navigateForward",
  • "Go Forward": "workbench.action.navigateForward",
  • "Go Back in Navigation Locations": "workbench.action.navigateBackInNavigationLocations",
  • "Go Forward in Navigation Locations": "workbench.action.navigateForwardInNavigationLocations",
  • "Go to Last Edit Location": "workbench.action.navigateToLastEditLocation",
  • "Go Back in Edit Locations": "workbench.action.navigateBackInEditLocations",
  • "Go Forward in Edit Locations": "workbench.action.navigateForwardInEditLocations",
  • "Go to Definition": "editor.action.revealDefinition",
  • "Go to Symbol in Workspace": "workbench.action.showAllSymbols",
  • "Focus Previous Search Result": "search.action.focusPreviousSearchResult",
  • "Focus Next Search Result": "search.action.focusNextSearchResult",
  • "Toggle Split Editor in Group": "workbench.action.toggleSplitEditorInGroup",
  • "Toggle Split Editor in Group Layout": "workbench.action.toggleSplitEditorInGroupLayout",
  • "Split Editor Right": "workbench.action.splitEditorRight"

@Z-E-D Z-E-D closed this as completed Mar 22, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants
@rebornix @bpasero @Z-E-D and others