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

Open server address link in new window #609

Closed
dotNomad opened this issue Dec 15, 2023 · 10 comments · Fixed by #807
Closed

Open server address link in new window #609

dotNomad opened this issue Dec 15, 2023 · 10 comments · Fixed by #807
Assignees
Labels
bug Something isn't working hold standalone-ui

Comments

@dotNomad
Copy link
Collaborator

dotNomad commented Dec 15, 2023

Created from Kelly O'Briant's feedback

I clicked the link for the server address while a deployment was running and got trapped there. I expected this to open in a new browser window.

I then couldn’t return to my in progress deployment. I clicked on the destination again and went into the logs. Is this the expected message? Did I bork it?

@dotNomad dotNomad changed the title Open server address link in new tab Open server address link in new window Dec 15, 2023
@dotNomad
Copy link
Collaborator Author

Will require some discovery to see if open-in-new-tab anchors easily work in VSCode.

@dotNomad dotNomad added the discovery Additional discovery is necessary to determine a solution label Dec 15, 2023
@dotNomad dotNomad added this to the Alpha (v1.0.alpha1) milestone Dec 15, 2023
@dotNomad dotNomad self-assigned this Dec 15, 2023
@dotNomad dotNomad added bug Something isn't working and removed discovery Additional discovery is necessary to determine a solution labels Dec 15, 2023
@dotNomad
Copy link
Collaborator Author

VSCode doesn't have a way to open in a new window using target="_blank" instead you have to call vscode.openExternal

@tdstein can you think of anyway we can get around this or utilize vscode.openExternal?

References

@dotNomad
Copy link
Collaborator Author

We can remove the link in the frontend, and if we cannot get links to work we can add a nice auto-copy on click to help users a bit.

@dotNomad dotNomad removed this from the Alpha (v1.0.alpha1) milestone Dec 15, 2023
@dotNomad
Copy link
Collaborator Author

dotNomad commented Dec 15, 2023

VSCode doesn't support target="_blank" and actively blocks it. More details can be found in references above. The links would still work if you used CMD clicking or middle mouse clicks which defaults to opening in a new tab (new window in VSCode), but if you clicked on them normally:

  • a target="blank" would be blocked and nothing would happen. A console error would be in the devtools that it was blocked
  • an external link would take over the iframe and the only way to navigate back is to use keyboard or mouse shortcuts like a normal browser. VSCode has no interface to back or navigate through history.

@dotNomad dotNomad removed their assignment Dec 15, 2023
@dotNomad
Copy link
Collaborator Author

@dotNomad dotNomad self-assigned this Dec 15, 2023
@dotNomad
Copy link
Collaborator Author

We can call the VSCode API by:

  • Have a onDidReceiveMessage listener function in the extension that determines what to do based on the object passed
  • adding a script to the Web View HTML that uses acquireVsCodeApi(), add an event listener for message, and use the message to do vscode.PostMessage to interact with the above
  • Use window.parent.postMessage in the Vue app to interact with the above

Example found here: #629

@tdstein
Copy link
Collaborator

tdstein commented Dec 18, 2023

VSCode doesn't have a way to open in a new window using target="_blank" instead you have to call vscode.openExternal

@tdstein can you think of anyway we can get around this or utilize vscode.openExternal?

References

At first glance, vscode.openExternal looks like the appropriate call for handling external links. Can you try calling this from the Vite application?

If it works, an onclick handler could call vscode.openExternal if acquireVsCodeApi returns non-null. Otherwise, do default target="_blank" behavior.

@dotNomad
Copy link
Collaborator Author

On hold for #646

@dotNomad dotNomad added the hold label Dec 18, 2023
@mmarchetti mmarchetti added this to the Alpha (v1.0.alpha2) milestone Dec 18, 2023
@dotNomad
Copy link
Collaborator Author

If it works, an onclick handler could call vscode.openExternal if acquireVsCodeApi returns non-null. Otherwise, do default target="_blank" behavior.

acquireVsCodeApi is not available in the Vite application because it is only available at the top-level of the VSCode extension webview. Inside the iframe it is not defined.

The target="_blank" behavior doesn't work either. Since VSCode doesn't have tabs the default behavior for a `target="_blank" link is to replace the current window.

@dotNomad dotNomad removed their assignment Dec 18, 2023
@dotNomad
Copy link
Collaborator Author

dotNomad commented Jan 9, 2024

I believe we can close this one up. By default anchors behave this way due to the way that VSCode injects the click listener described in #759.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hold standalone-ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants