cmd/tsconnect: fix xterm.js link opening not working when rendered into another window

The default WebLinksAddon handler uses window.open(), but that gets blocked
by the popup blocker when the event being handled is another window. We
instead need to invoke open() on the window that the event was triggered
in.

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita 2022-09-12 11:48:19 -07:00 committed by Mihai Parparita
parent f03a63910d
commit 11fcc3a7b0

View File

@ -23,7 +23,9 @@ export function runSSHSession(
term.open(termContainerNode)
fitAddon.fit()
const webLinksAddon = new WebLinksAddon()
const webLinksAddon = new WebLinksAddon((event, uri) =>
event.view?.open(uri, "_blank", "noopener")
)
term.loadAddon(webLinksAddon)
let onDataHook: ((data: string) => void) | undefined