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

web view context menu: context keys don't seem to work #156416

Closed
aeschli opened this issue Jul 27, 2022 · 2 comments · Fixed by #156485
Closed

web view context menu: context keys don't seem to work #156416

aeschli opened this issue Jul 27, 2022 · 2 comments · Fixed by #156485
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@aeschli
Copy link
Contributor

aeschli commented Jul 27, 2022

Testing #156224

Version: 1.70.0-insider
Commit: 9cf2fab
Date: 2022-07-27T05:17:51.709Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Darwin x64 21.5.0

Following the steps from #156224, I get context menus in web views, but using the context from data-vscode-context doesn't seem to work. Hope I didn't misunderstand the way this should work.

Find the complete sample code here: https://github.com/microsoft/vscode-extension-samples/tree/aeschli/webviewtesting

				<div class="menu" data-vscode-context='{"webviewSection": "menu", "countOfThing": 123}'>
					<h1>Menu</h1>
					<div class="nav" data-vscode-context='{"webviewSection: "nav", "preventDefaultContextMenuItems": true}'>
						NavNavnavNav22
					</div>
				</div>

to the HTML body

  • defining two context menu entries:
		"menus": {
			"webview/context": [
				{
					"command": "catCoding.foo",
					"when": "webview == 'catCoding' && webviewSection == nav"
				},
				{
					"command": "catCoding.doRefactor",
					"when": "webview == 'catCoding'"
				}
			]
		},
  • run the sample, run the Start cat coding session command
  • Right click on NavNavnavNav22.
    -> doRefactor appears, but not foo. Also are all the default commands are present on NavNavnavNav22
@mjbvz
Copy link
Collaborator

mjbvz commented Jul 27, 2022

This is because the json is invalid (it probably was just copied from from the example). There needs to be a closing quote on webviewSection

I'll add some logging to make this error more clear

@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Jul 27, 2022
@mjbvz mjbvz added this to the July 2022 milestone Jul 27, 2022
mjbvz added a commit to mjbvz/vscode that referenced this issue Jul 27, 2022
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jul 27, 2022
@aeschli
Copy link
Contributor Author

aeschli commented Jul 27, 2022

Thanks, now all works great!

@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 28, 2022
@connor4312 connor4312 added the verified Verification succeeded label Jul 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants