Reputation: 867
We have created a unique VSCode WebView extension, strictly for our own internal use. This WebView provides the ability to capture Domain Driven Design models that are code generated into Microservice API. One of the type editors we added supports JSON Schema, and we utilized an OpenSource React component to implement this editor. We were extremely careful to not implement any popups with the WebView extension however this JSON Schema editor does implement a number of modal dialogs which do not surface when inside our custom VSCode WebView extension.
I am looking for a workaround to the restriction in VSCode WebView Extension.
Upvotes: 3
Views: 3419
Reputation: 65663
VS Code intentionally blocks modals in webviews. See this issue for more details on why but in summary:
The correct way to collect user input from a webview is to send a message from your webview back to your extension that invokes VS Code's normal UI APIs—such as showQuickPick
or showInformationMessage
. If the library you are using does not allow you to inject a custom prompting method, then you could try overriding globals such as window.alert()
to hook them up to the corresponding VS Code API
Upvotes: 3
Reputation: 1
You are correct. To resolve this issue we are changing to sliding windows. This does work. It's a shame that this restriction exists as it will limit the use of 3rd party controls that rely on user interaction through modal dialog.
Upvotes: 0
Reputation: 158
As far as I know, Currently vscode webview blocks popups by default, the only way to use modal/popup in webview is by using vscode.window.showInformationMessage("message",{modal:true}) which either resolves or rejects based on user action.
Upvotes: 2