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

Custom tree view menu items are not refreshed when context is changed #8757

Closed
tal-sapan opened this issue Nov 17, 2020 · 3 comments
Closed
Labels
help wanted issues meant to be picked up, require help vscode issues related to VSCode compatibility

Comments

@tal-sapan
Copy link
Contributor

tal-sapan commented Nov 17, 2020

Bug Description:

I have a custom tree view and I am trying to implement a toggle button behavior in its menu.
I added 2 commands to the view/title menu of the my view. Each of the commands has a when clause that checks a context variable which I set with the setContext built-in command. When I click on the button (which triggers the commands) I change the context so that it will show the other command.
The expected behavior is that once I set the context, the menu will be refreshed and show the other button. However, it is not refreshed until I move the mouse cursor outside the view and return it again:
refresh_issue

This works as expected in VSCode (the menu is refreshed immediately).

Relevant definitions in the package.json file:

"contributes": {
  "views": {
    "explorer": [
      {
        "id": "testView",
        "name": "Test View"
      }
    ]
  },
  "menus": {
    "view/title": [
      {
        "command": "treeviewmenurefresh.firstCommand",
        "group": "navigation@0",
        "when": "view == testView && treeviewmenurefresh.enabledCommand == first"
      },
      {
        "command": "treeviewmenurefresh.secondCommand",
        "group": "navigation@1",
        "when": "view == testView && treeviewmenurefresh.enabledCommand == second"
      }
    ]
  }
}

The commands each show a notification and change the context using:

// the type variable is a string with the value "first" or "second"
await vscode.commands.executeCommand(
  'setContext',
  'treeviewmenurefresh.enabledCommand',
  type
);

You can see the full implementation here: https://github.com/tal-sapan/treeviewmenurefresh

Steps to Reproduce:

  1. Build the extension above using npm install && npm run bundle
  2. Open Theia with this extension
  3. Open the Test View panel
  4. Click on the "zoom in" icon in the menu. Expected behavior: a notification is displayed and the button icon changes to the "zap" icon (meaning the first command is not displayed and the second command is displayed). Actual behavior: the notification is displayed but the button is not changed.
  5. Move the mouse cursor outside the view and back again to the the view. The icon is changed and the second command is displayed.

Additional Information

  • Operating System: Windows 10 (also tested on a Linux system)
  • Theia Version: built from master (also tested on Theia 1.7.0)
@colin-grant-work
Copy link
Contributor

It seems that this is an issue with quite a bit of interest. I missed this existing issue, filed my own, and created a PR here: #8967.

@amiramw
Copy link
Member

amiramw commented Mar 8, 2021

According to @danarad05 #9080 and #8967 both solve this. We should retest after they are merged.

@colin-grant-work
Copy link
Contributor

I believe that this issue has been resolved by #10546. If you encounter this issue again, please do let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted issues meant to be picked up, require help vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants